Briefly put, the issue is this: a few seconds after having the program running, the pollEvent function in one of its iterations takes a long time (more than 1 second) to do whatever it does.
1) This lag spike happens only once in the entire execution, and it only happens some time within the first 5 seconds of execution. It will run normally after that.
2) I had this problem with SFML 2.0 and now with SFML 2.3.2.
3) I'm using sf::RenderWindow.
This is the code:
...
while(window.isOpen()){
sf::Event ev;
sf::Clock cl;
while(window.pollEvent(ev)){
printf("ev.type = %d took %.6fs\n", ev.type, cl.restart().asSeconds());
if (ev.type == sf::Event::Closed){
window.close();
}
}
}
...
First execution:
Second execution:
Third execution:
Detailed description: I run the executable, it opens the window and runs the code fine, display whatever it has to display, 2-5 seconds after started, the lag spike happens. It doesn't matter if I let the mouse resting on screen or off-screen, if I don't move the mouse during this first 5 seconds, the next time I move the mouse, the lag spike will happen, 100% of the times.
I'm running Windows 10 and MinGW-4.9.3 compiler, although it also happened when using Windows 8.1 and some other previous MinGW version that I can't recall.
Thanks for helping!