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

Author Topic: SFML2: MouseMove events stalling event loop  (Read 2139 times)

0 Members and 1 Guest are viewing this topic.

Kanpachi

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML2: MouseMove events stalling event loop
« on: June 29, 2012, 12:52:57 am »
Today I decided to make the jump to the SFML 2.0RC from 1.6, but since I have I've noticed a serious problem with MouseMove events causing my event loop to stall until I stop moving the mouse. Here are some code samples to demonstrate what I mean:

#include <SFML/Window.hpp>
#include <iostream>

int main() {
    sf::Window win(sf::VideoMode(1024, 600), "SFML 1.6");
    sf::Clock clock;

    while (win.IsOpened()) {
        sf::Event e;

        float elapsed = clock.GetElapsedTime();
        clock.Reset();

        std::cout << elapsed << std::endl;

        while (win.GetEvent(e)) {
            if(e.Type == sf::Event::Closed) win.Close();
        }

        win.Display();
    }
    return 0;
}

Simple program using SFML 1.6. The 'elapsed' variable is assigned a consistent value (about 0.016) every iteration even when I move the mouse around the window, so this works as expected.


#include <SFML/Window.hpp>
#include <iostream>

int main() {
    sf::Window win(sf::VideoMode(1024, 600), "SFML 2.0");
    sf::Clock clock;

    while (win.isOpen()) {
        sf::Event e;

        sf::Time elapsed = clock.getElapsedTime();
        clock.restart();

        std::cout << elapsed.asMilliseconds() << std::endl;

        while (win.pollEvent(e)) {
            if(e.type == sf::Event::Closed) win.close();
        }
        win.display();
    }
    return 0;
}

The same program's SFML 2.0RC 'equivalent'. If I leave the window alone, the program prints out a consistent 16 ms every iteration, as I expect. If I start moving the mouse around the window, though, it gets stuck in the event loop until the mouse pointer either leaves the window or stays completely still. The result is that the next printout of the elapsed time is much longer (2000 ms if I move the mouse around continuously for 2 seconds, etc).

Any thoughts? I'm using Windows 7 x64, the most recent SFML 2.0RC from the downloads page, dynamically linking to the SFML libraries, and this happens in both debug and release modes.

edit: Oh yes, I'm also using the GCC DW2 version of the SFML libs. My compiler is GCC 4.4.0.
« Last Edit: June 29, 2012, 06:29:36 am by Kanpachi »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML2: MouseMove events stalling event loop
« Reply #1 on: June 29, 2012, 08:21:03 am »
What's your mouse? Is it a high-resolution one?
Laurent Gomila - SFML developer

Kanpachi

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: SFML2: MouseMove events stalling event loop
« Reply #2 on: June 29, 2012, 03:50:53 pm »
I use this mouse, which has an adjustable resolution. The same effect happens whether the mouse resolution is set to 400 or 5000 dpi. Also, I notice the same behaviour while using another less-fancy mouse. It also seems to happen on the SFML examples packaged with 2.0.

I notice a similar but not quite so pronounced effect if I play with the joystick axes while running the same 2.0 program, but nowhere nearly as bad as the mouse. It might stall 30 ms at worst.

Kanpachi

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: SFML2: MouseMove events stalling event loop
« Reply #3 on: June 30, 2012, 06:13:29 pm »
Ok, fixed, kinda.

It doesn't seem to happen if I build the libs from the latest snapshot of the git repo.

I'm happy with that as a solution for now, but this suggests there's something that needs to be addressed in the release candidate.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML2: MouseMove events stalling event loop
« Reply #4 on: June 30, 2012, 07:12:23 pm »
Hum... As far as I remember, nothing has changed for mouse events since the RC ???

There was a "fix" for a bug related to joysticks on Windows, but I don't think it can be linked to this mouse issue.
« Last Edit: June 30, 2012, 07:14:47 pm by Laurent »
Laurent Gomila - SFML developer

Kanpachi

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: SFML2: MouseMove events stalling event loop
« Reply #5 on: July 01, 2012, 05:13:29 am »
It gets stranger.

Hoping to get to the bottom of this, and because I'm not 100% comfortable working from a repo snapshot, I rolled back to the release candidate. Now, mouse events seem to magically work fine, but I can only link the libs statically. Otherwise I get Entry Point Not Found errors when I load my app, suggesting that the precompiled lib files in the RC download are mismatched with the included DLLs. And funnily enough, the DLLs I built myself work fine with the precompiled libs in the RC.

I'm happy with static linking but if anyone has any thoughts on why I can't seem to use the DLLs in the RC download, they would be much appreciated.


Flonk

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: SFML2: MouseMove events stalling event loop
« Reply #6 on: July 29, 2012, 07:02:03 pm »
I just found the thread, and I have the same problem. The problem appears in all Examples and self-compiled programms (the SFML 2.0 ones, not my old 1.6 ones).
I am using Windows 7 64bit and MingW JSJL.
Next thing I will do, is to try compile it myself and report back with the results, although my static linking doesn´t work for now, but I think, that is a configuration error on my side.

 

anything