Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: window.poll() lags on my desktop PC  (Read 1683 times)

0 Members and 1 Guest are viewing this topic.

szpaq234

  • Newbie
  • *
  • Posts: 3
    • View Profile
window.poll() lags on my desktop PC
« on: April 09, 2016, 05:06:38 am »
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;
}
 
« Last Edit: April 10, 2016, 10:43:43 pm by eXpl0it3r »

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: window.poll() lags on my desktop PC
« Reply #1 on: April 09, 2016, 08:15:12 am »
What about configuration of your pc (e.g. how many bits, which os, ram etc.). "desktop pc" doesn't give much information  ;).

szpaq234

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: window.poll() lags on my desktop PC
« Reply #2 on: April 09, 2016, 09:07:34 am »
On both machines I run SFML in 64bit mode with DLLs. I mentioned OS. Only hardware that can impact this in any way is Radeon R9 on my desktop.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: window.poll() lags on my desktop PC
« Reply #3 on: April 09, 2016, 09:55:14 am »
Do you have a gamepad plugged in?

Get the debug libraries and run it in a profiler/debugger to figure out where it gets stuck.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

szpaq234

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: window.poll() lags on my desktop PC
« Reply #4 on: April 09, 2016, 07:24:38 pm »
It might be it. I unplugged and it works normally. That would also explain why it works normally on my laptop.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: window.poll() lags on my desktop PC
« Reply #5 on: April 09, 2016, 10:59:07 pm »
win32 api's fault :P

 

anything