window.poll() sometimes gets stuck. What exactly happens is program spins in the while loop and occasionally window.poll() takes up to 7s !!! to execute. Below is minimal code that causes the problem and as you can see, there's nothing that would interfere with the window even remotely. It seems that sfml doesn't like my PC. This happens only on my desktop running Win10. It work normally on my laptop that also runs win10. Any thoughts ?
I did a quick test, no event is actually being caught during the lag.
#include <SFML/Graphics.hpp>
#include <chrono>
int main()
{
sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
while (window.isOpen())
{
std::chrono::milliseconds t1 = std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::system_clock::now().time_since_epoch());
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
std::chrono::milliseconds t2 = std::chrono::duration_cast<std::chrono::milliseconds>
(std::chrono::system_clock::now().time_since_epoch());
int dur = (int)((t2 - t1).count());
if (dur > 20)
printf("%d\n", dur);
window.clear(sf::Color::Black);
window.display();
}
return 0;
}