Eventpolling taking hundreds of ms on some windows systems

I recently did some work to upgrade World of Goo for 2D Boy to modern systems. However one issue that is outstanding after the release is that on Windows some users are experiencing a periodic lag every 1-2 seconds of around 100ms -> 300ms. I’ve isolated it down to an issue with the SDL2 event pump as it’ll take 100->300ms sometimes to run SDL_PollEvent and returning 0 actual events to process!.

Right now we are using SDL 2.0.9 I’m having the users test with the oldest I can use (2.0.7) due to SDL2 mixer and other APIs we are using (GetDisplayUsableBounds)…

Does anyone have suggestions about what might be impacting things here? Or how I can help triage things better on customers system? (as I can not recreate the issue on my system, nor can Kyle @ 2D Boy recreate it on his systems)


The macOS and Linux ports are smooth as butter running on SDL 2.0.9 :smiley:

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).

Thanks Daniel, for the quick reply! Kyle and I have been scratching our head excessively around this one!.

1 Like

You’re welcome! :slight_smile:
Yeah, it’s a nasty bug - I was super lucky that on my system it occasionally caused freezes that lasted several seconds so I had enough time to switch to the debugger and hit break to look at the backtrace