SDL2.0.9 regression: frame drop every 180 frames (win10, 64bit, vsynced renderer)

System: Windows 10,

Hi all,
i would like to report a regression. i am repeatedly rendering an image to a SDL window using an hardware accelerated renderer and vsync enabled.


if i precisely measure the duration timings using high_resolution_clock::now(), i mostly get exactly the right duration of 16.666 ms, but strangely every three seconds aka 180 frames there is a small drop in performance:

frame drop after 180 dt=0.0302229
frame drop after 180 dt=0.030091
frame drop after 180 dt=0.0300536

the strange thing is: the more webcams ( i have two webcams) i attach to my computer, the longer dt gets.

There must be a problem with SDL_PollEvent (that i call every frame.)

If i call SDL_PollEvent only every 250 frames, i then get a more pronounced frame drop:

frame drop after 250 dt=0.164816
frame drop after 250 dt=0.166964

now, if i switch back to the 2.0.8 release, the problem is non-existing anymore ! so something went wrong somewhere with the latest release.

This is a known bug in SDL 2.0.9, which is already fixed in the hg code,
so it will be fixed in 2.0.10, see - a short(-ish) explanation of the bug can also be found at SDL2: lag with SDL_GetTicks.

A workaround is to add SDL_INIT_JOYSTICK to your call to SDL_Init()
(yes, even if you don’t want to use any joysticks and don’t even have
any connected to your PC).

Thank you very much for the quick reply!
Btw., I was already panicking having a Trojan on my pc taking screenshots every 3 seconds…
Relieved that it’s just a sdl bug.

waoooo, thanks for this information !!! I’m looking to understand this problem for more than a week… I also made a little program to test these missing frames :

you can test the effect of add or removing the SDL_INIT_JOYSTICK option at line 150.