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


#1

System: Windows 10, SDL2-devel-2.0.9-VC.zip

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.

renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

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.


#2

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
https://bugzilla.libsdl.org/show_bug.cgi?id=4391 - 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).


#3

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.