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

Author Topic: Window not responding you may choose to wait  (Read 7382 times)

0 Members and 1 Guest are viewing this topic.

dulsi

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Window not responding you may choose to wait
« on: February 08, 2016, 05:16:28 am »
I've been porting Ostrich Riders to the SFML 2.3.2. I've got it working but soon after starting it complains a with:

“Ostrich Riders 0.6.1” is not responding.

You may choose to wait a short while for it to continue or force the application to quit entirely.

If you wait everything works fine. I'd like to stop the message from appearing. I played around with the sample from here. Just had to fix the path to the font. That still gets the message. Suspecting that anything using pollEvent gets the error, I switched to waitEvent. No error but obviously doesn't display properly. I moved the waiting for events in a separate thread. That works for a while. Eventually you get:

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.

Using Fedora 23, is it possible to avoid the "not responding" message window? Do any examples using pollEvent avoid this message? If you must use waitEvent is it possible to use it in a separate thread from the window drawing without causing it to crash?

Here is a simple example I tried with a thread. I've tried both drawing in the main thread and waiting for events in the main thread. Neither made a difference. (Don't worry about the use of globals or anything. I'm just doing a proof of concept which oviously hasn't worked.)

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <cstdlib>
#include <ctime>

enum State { Closed, Normal } ;

void update_normal(sf::RenderWindow & w ) ;

const std::string fontLocation = "/usr/share/fonts/liberation/LiberationSans-Regular.ttf" ;
sf::Font font ;

State state;
sf::RenderWindow *win;

struct ConsumeEvent
{
public:
 void operator()();
};

void ConsumeEvent::operator()()
{
    while ( win->isOpen() )
    {
        if ( state == Closed )
        {
            win->close() ;
            continue ;
        }

        win->clear() ;
        update_normal(*win) ;

        win->display() ;
    }
}

int main()
{
    std::srand(std::time(0)) ;
    sf::RenderWindow window( sf::VideoMode(800,600), "Pause me!") ;
    window.setFramerateLimit(60);
    win = &window;
    state = Normal;

    if (!font.loadFromFile(fontLocation))
        return 0 ;

    ConsumeEvent c;
    sf::Thread t(c);
    t.launch();
    sf::Event event ;
    while ( win->waitEvent(event) )
    {
        switch(event.type)
        {
        case sf::Event::Closed:
            state = Closed ;
            break ;
        default:
            break ;
        }
        if (state == Closed)
         break;
    }
    t.wait();
}

void update_normal(sf::RenderWindow & w )
{
    static sf::Text text("Running!", font) ;
    text.setColor( sf::Color(63, 127, 127) ) ;
    text.setPosition( 200 + std::rand() % 50, 275 + std::rand() %50 ) ;
    w.draw(text) ;
}
 

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #1 on: February 08, 2016, 06:23:47 am »
Only one question.

Why use multithreading? On event handling/drawing you lose performance instead of gain it.
I would like a spanish/latin community...
Problems building for Android? Look here

dulsi

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #2 on: February 08, 2016, 12:52:09 pm »
Why use multithreading? On event handling/drawing you lose performance instead of gain it.
I don't want to use multithreading. I want to stop the window saying the application isn't responding and having to click wait. I have not found a way of doing that using pollEvent in a single thread. If you know how to fix that I'd gladly use that instead of multi threads.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Window not responding you may choose to wait
« Reply #3 on: February 08, 2016, 02:20:34 pm »
Do you mean that the application is never responding, or only in specific circumstances (like when you move or resize it)?
Laurent Gomila - SFML developer

dulsi

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #4 on: February 08, 2016, 02:26:40 pm »
Do you mean that the application is never responding, or only in specific circumstances (like when you move or resize it)?
The application is responding. It is running just fine. Fedora just doesn't believe it is for some reason. So to run Ostrich Riders, I start the program, let the window saying it isn't responding popup, click on wait, and then play the game. I took this simple example, fixed the location for the font, and ran it. It too popped up the window saying it isn't responding. I don't try moving or resizing the window. It's just a simple pollEvent loop that causes the warning.

Edit: Now I can't recreate the problem with the example program I mentioned. M.A.R.S. is in Fedora, uses SFML and doesn't have the problem. I don't know why Ostrich Riders isn't working.
« Last Edit: February 08, 2016, 05:20:09 pm by dulsi »

dulsi

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #5 on: February 08, 2016, 09:36:27 pm »
I think I figured out the problem. The game created the window then loaded a bunch of images and sounds. Finally it started the game loop with pollEvent. If I add a pollEvent before the loading the images and before loading the sounds, the popup doesn't occur. (At least most of the time. There was a another screen switch where I saw it once so that might need some modification.)

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #6 on: February 08, 2016, 11:38:50 pm »
Do you remember to drain the event queue completely in your pollEvent loops (and do so regularly)? You should.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Window not responding you may choose to wait
« Reply #7 on: February 09, 2016, 10:39:50 am »
How much image data are you loading then?

Windows will only start complaining that the window is not responding after a few seconds of no event processing, but if a game is getting stuck for a few seconds, then it's usability wise anyways recommended to do the image loading asynchronously and render some progress bar. Keep in mind that if you do load things asynchronously, you should really only load data from disk to memory and not do anything with OpenGL.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

dulsi

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Window not responding you may choose to wait
« Reply #8 on: February 09, 2016, 03:59:31 pm »
How much image data are you loading then?

Windows will only start complaining that the window is not responding after a few seconds of no event processing, but if a game is getting stuck for a few seconds, then it's usability wise anyways recommended to do the image loading asynchronously and render some progress bar. Keep in mind that if you do load things asynchronously, you should really only load data from disk to memory and not do anything with OpenGL.
It's not loading a lot of data. Fedora must be configured to popup the message much earlier than windows. It's take a second or less to display the starting screen at which point it is calling pollEvent. Interestingly the popup takes a while before it loads. That combined with the fast startup caused me to not consider the image/sound files loading to be a problem. When I commented out all the processing and still received the error I looked at the loading code. Loading asynchronously is not worth the complexity at the moment. I modified it to simply load everything before creating the render window.

TmCrafz

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Window not responding you may choose to wait
« Reply #9 on: October 03, 2016, 02:18:15 pm »
I have the same problem as dulsi. The message that the window is not responding is shown although all is working well. If i said wait all works perfect. I do handle events every frame. The solution of dulsi fix the problem for me. I poll events direct after creating the window and then I load the needed stuff (Not very much, only a Font and creating some sf::Text). Im using Ubuntu 16.04 and SFML 2.3.2 from the Ubuntu repositories.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Window not responding you may choose to wait
« Reply #10 on: October 03, 2016, 02:40:00 pm »
Use the 2.4.x branch which contains a fix for this issue and build from source.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/