Unstable frame rate unexpectedly

Do you guys experience this problem

in random time, vsync on, your frame rate drops below the stable one (60 or in my case 52 due to my refresh rate of monitor) . I tested many times before with the exact same demo, it will be stable, but just in unpredictable time (random) like 1 out of 10 it will become unstable until you restart computer or enough time pass, something along this line.

Sorry for my vagueness in describing the situation, but in short, it performs stable before it goes unstable with the same setup. Anyone experiences this before? How to solve this?

Is this SDL 2.0.9 on Windows?
Try passing SDL_INIT_JOYSTICK to SDL_Init() , that works around a bug in 2.0.9 that can cause frames to take longer than they should.
(Yes, this helps even if you don’t have any joysticks or don’t plan to support them in your program)

1 Like

Thank you for fast reply!

That’s interesting. Although I’m on macOS (and pretty much almost tip of SDL2 source pulling down) at the moment, but I tried and that helps as well. I’ll report back if I see opposite result in the result. Hope this bug will get fixed too.

Thanks Daniel!

Good to know this is not just a problem on Windows!
(Makes sense, nothing of the issue was Windows-specific, but so far the delays had only be observed there. It comes from iterating the system’s input devices, I thought other systems did this faster than Windows. BTW, it’s already fixed in hg)

@icculus @slouken: Do you have any plans for 2.0.10 yet? We should really get the fix released…


Update The problem goes back again. I will try pulling latest SDL2 tonight. Currently i’m basing off 12569:05aff4771d9a of SDL2.

There is a Mac issue with framerate due to this change, apparently: https://hg.libsdl.org/SDL/rev/ffd52bb02bcc

So if not opening an audio device makes the framerate stop being weird, that’s a known issue I’m tackling in the next few days.

1 Like

Hey thanks Ryan.

For clarity, do you mean I should open audio device via SDL_Init even I don’t need it to stop making framerate drop to happen? Currently I don’t initialize SDL_INIT_AUDIO.

If you aren’t initializing audio, this is not the problem.

well i will be damned. i added the SDL_INIT_JOYSTICK def to my init and indeed the weird frame spikes are gone. i thought i was going crazy! i posted in another thread earlier because of this. i tried reinstalling my previous versions i was developing with back when i was working on my little project (v2.0.5) and i wasn’t having those issues!