lime
lime copied to clipboard
SDL_GetTicks Noticeably Imprecise
SDL_GetTicks
is only accurate to the millisecond, which results in deltaTime
values being rather imprecise. This is immediately observable in the FPS display, which is inaccurate by a couple frames:
In other words, if you have an application running at 60 fps, you would expect a delta time of roughly 1666
(1000 / 60 = 16.66667
) at least, but you're instead just given 16
.
A piece of the relevant code (SDL_GetTicks
is used in several relevant places in this file):
https://github.com/openfl/lime/blob/862fe55b1cf567bdfb4ada7d5bc78be36353f9e6/project/src/backend/sdl/SDLApplication.cpp#L132
How interesting, I might fix this in a private repository of mine
For reference: In Flash, which OpenFL is based on, the only option for timing is flash.utils.getTimer()
, which also has millisecond accuracy.
I thought this only affected the frame rate counter, but the event loop delta is actually wrong due to this. Perhaps we should implement the timing for the main loop like Starling and use a float. I will look into this more.
I will look into this more.
Sounds good. I hope that you'll wait to commit until after OpenFL 9.2 is released. This sounds like something that should be in dev builds for a while, just to ensure that there aren't any unintended side effects.
No worries there. The event loop is a critical, core component obviously and any changes should be carefully considered and well tested. There's not enough time to even attempt to fit it into the next release even if I wanted to try. 😂