# Eventpolling taking hundreds of ms on some windows systems

**URL:** <https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129>\
**Category:** SDL Development\
**Created:** [May 9, 2019, 9:32pm UTC](https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129 "2019-05-09T21:32:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Rudd](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/edward_rudd/32/180_2.png) [@Edward\_Rudd](https://discourse.libsdl.org/u/Edward_Rudd)\
**Post date:** [May 9, 2019, 9:32pm UTC](https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129/1 "2019-05-09T21:32:18Z")

</div>

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)

Edward,

P.S.  
The macOS and Linux ports are smooth as butter running on SDL 2.0.9 😃

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [May 9, 2019, 9:44pm UTC](https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129/2 "2019-05-09T21:44:23Z")

</div>

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](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](https://discourse.libsdl.org/t/sdl2-lag-with-sdl-getticks/25538/6)

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

---

<div class="post-metadata">

**Author:** ![Edward\_Rudd](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/edward_rudd/32/180_2.png) [@Edward\_Rudd](https://discourse.libsdl.org/u/Edward_Rudd)\
**Post date:** [May 9, 2019, 11:42pm UTC](https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129/3 "2019-05-09T23:42:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Daniel\_Gibson](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/daniel_gibson/32/3010_2.png) [@Daniel\_Gibson](https://discourse.libsdl.org/u/Daniel_Gibson)\
**Post date:** [May 9, 2019, 11:57pm UTC](https://discourse.libsdl.org/t/eventpolling-taking-hundreds-of-ms-on-some-windows-systems/26129/4 "2019-05-09T23:57:22Z")

</div>

You’re welcome! 🙂  
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
