-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
SDL Example: Assertion io.DeltaTime >= 0 in examples when FPS is very high #996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Your suggested fix is incorrect at it will create spikes of delta time. Those times are used for various time measurement (mostly the double click and various repeat speed). You should investigate why you are getting a negative DeltaTime in the first place. |
I just compile the example and get this issue. I believe its due to hardware and/or MinGW. Windows 10 How do I remedy this in a good way using code? |
Okay! I tested a new way to fix it and it worked. Let me know if it's better.
I had to change the type of g_Time to Uint32 near the top of imgui_impl_sdl_gl3.cpp too. |
I'd also like to mention that the example is constantly spamming the assertion when ran. |
Could you log, say, the 1000 first values returned by SDL_GetTicks() in that case and then dumping them out? Something like:
|
Here's another log I did using the following code
During the log, I had to click "Ignore" on many, many exceptions... |
One more test I did that makes sure the log is even more representative
Once again I had to click "Ignore" on many, many exceptions, but all for io.DeltaTime. |
EDIT: I fixed it in the above post. I also found that my compiler optimization flag doesn't seem to matter when compiling the example. |
It seems as if my fix would work if the library allowed io.DeltaTime = 0 (see the referenced issue) |
I haven't have time to look at it. Allowing io.DeltaTime = 0.0f makes little sense and even if some workaround would be possible in term of handling buttons, other things would break. Make sure your app doesn't give DeltaTime 0.0 (the sdl2 example code probably needs fixing as you suggested above, but passing 0.0f isn't a correct fix). |
Replying here instead of the other closed thread.
It's incorrect to give a zero DeltaTime. If your application wants to deal with 1000+ FPS framerate then surely your application shouldn't be using a millisecond precision timer? If you can get a precise enough value at least uses 1.0f/FPS instead of zero.. |
Okay. That makes sense I guess. I'll go ahead and limit FPS at 1000 for my application. Thanks! The original issue still applies, and fixing the example is more involved as it needs to have it's FPS capped. |
Yes there's probably an issue with that SDL2 example, I will look at it. |
Good suggestion. Thanks! That does make the timing less accurate, but I guess it would go unnoticed. |
If you are using C++11 then maybe use this: http://stackoverflow.com/questions/26440860/sdl-getticks-accuracy-below-the-millisecond-level |
Does ImGui use cumulative time for anything? If so, nanoseconds is probably too much for a float. EDIT: oh, i guess we could just cast to seconds though. whoops! |
If you up convert the units it still won't be zero.. |
SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency() can be used for a more precise timer.
|
…Frequency() to handle framerate over 1000 fps properly. Noticed bad inputs artefacts in Nav branch at 2000 fps without this. (#996)
@Wizzard033 I finally got around to fix this (using the performance counter as suggested by @AlfonsoJLuna). My apologies Brandon for taking so long to tackle such a simple problem. Today I was testing Navigation branch input and the problem was very noticeable due to how the Nav branch handle its inputs (it's currently not tolerant to Note that I also changed the SDL example to enable vsync so they'll probably be capped to 60 hz etc. by default but I tested it for high framerates. |
Uh oh!
There was an error while loading. Please reload this page.
The following line in imgui_impl_sdl_gl3.cpp fails very often
It fails due to the assertion io.DeltaTime >= 0 which isn't true here
I see this same line in a lot of the examples, and I don't know how it's managed to get this far
Maybe it is just a MinGW thing that causes this to be negative at very high framerates (5000+)
My fix I did follows
The text was updated successfully, but these errors were encountered: