Hey all,
Second help post here, hopefully this one is easier to solve
I am having trouble with calls to sf::Window::pollEvent , which usually take 0 milliseconds but spike to 10, 20 even 60 ms at times. I have not been able to localize it further than that. On the internet I have read that in the past this was due to joysticks?
My environment:
- Windows 10 x64 build 1709
- SFML 2.4.2 (x86) or the latest master branch version
- Visual Studio 2017 Community 15.5.6
- Cmake version 3.6.2
- I am using statical linking
I am not using joysticks for my game as input devices. The source code can be viewed here:
https://github.com/TijmenUU/smarttalesii, but it specifically happens in
https://github.com/TijmenUU/smarttalesii/blob/master/smart_tales_ii/inputhandler.cpp line 22.
Both SFML 2.4.2 (x86) and latest master version have this issue for me.
Interesting observation: I sometimes have 2 xbox controllers plugged in, like this guy over here has too
https://stackoverflow.com/questions/46135226/sfml-fps-problems-with-window-event-polling. I will test if plugging 1 or 2 in makes any difference.
If this is a known issue: can I remove joystick support easily by altering the source and rebuilding SFML?
EDIT: Plugging two xbox controllers in does not get rid of the problem, but it does "seem" to reduce the occurrences of them. No hard evidence for that, problem still persists. My logs still show 27 ms spend on line 22.
Before anyone asks: I have put loggers all over my update cycles to see where the problem occurred, and it is definitely the sf::Window::pollEvent function, it never occurred in other places. So it is not an outside influence I happen to record randomly on that line.
EDIT2: My measurement is implemented as follows in the previously mentioned file inputhandler.cpp:22:
sf::Clock timer;
sf::Event event;
while (window.pollEvent(event))
{
logger << "poll_ev_time " << timer.restart().asMilliseconds() << '\n';
switch (event.type)
And in my log file it looks like this:
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 22
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 3
poll_ev_time 0
poll_ev_time 0
poll_ev_time 1
poll_ev_time 0
poll_ev_time 1
poll_ev_time 0
poll_ev_time 0
poll_ev_time 0
poll_ev_time 6