| Summary: | SDL event polling gets slower over time | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Laron Doettenberg <laron.doettenberg+bugzilla.libsdl.org> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.9 | ||
| Hardware: | x86_64 | ||
| OS: | macOS 10.13 | ||
| Attachments: | Sample log output showing frame time vs frequency of mouse movement polling | ||
Never mind! Problem exists between chair and keyboard. My game loop is progressively rendering more and more frequently as it accumulates time. Thanks for being a rubber duck :) |
Created attachment 3843 [details] Sample log output showing frame time vs frequency of mouse movement polling Note: My Mac OS X version is 10.14 (it wasn't listed in the OS selection) I'm using SDL to process input in a small game I'm working on. I've just got some drag-and-drop stuff working in a menu but I noticed something super weird: as the game runs, the drag-and-drop gets more stuttery and jumpy over time. My frame rate is roughly 60 FPS, but when the game loop starts the mouse events are only firing every 2 frames or so and then become less frequent over just a few seconds. I see lots of complaints online about SDL_PollEvent being slow, but the solves for those cases are exactly what I'm already doing: running SDL_PollEvent in a loop. What am I doing wrong here? I'm using SDL2 2.0.9 and the problem exists on 2.0.8 as well. This is the event processing loop from the top of my game loop: void poll_events() { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_WINDOWEVENT: handle_window_event(event.window); break; case SDL_MOUSEMOTION: handle_mouse_motion_event(event.motion); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: handle_mouse_button_event(event.button); break; case SDL_MOUSEWHEEL: handle_mouse_wheel_event(event.wheel); break; case SDL_KEYDOWN: case SDL_KEYUP: handle_key_event(event.key); } } } I've attached a sample of my log output showing frame time vs frequency of mouse movement events.