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

Author Topic: [SFML 2.0] Strange Problem if Window is on Foreground!  (Read 8618 times)

0 Members and 1 Guest are viewing this topic.

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
[SFML 2.0] Strange Problem if Window is on Foreground!
« on: May 08, 2012, 04:22:44 pm »
Hello,

First, -> I use Windows 7 Professional!

yeah, the Title is a little bit involved... The problem is, if I create a Window with
SFML and it is on the Foreground, it's lagging if I try to switch as example to Firefox,
with the Mouse and the Taskbar its lagging, with Alt + Tab not!

The Task in the Task Bar becomes after seconds (like 15 seconds) a Color that it
is selected or if I click directly on the Task it needs again like 15 seconds to switch to the Program.

My Hardware Components are good enough... this is not the Problem, and I don't remember
that this strange Problem exists with SFML 1.6...

A Picture...


I draw the position of the Mouse on the Screenshot, normaly the Task in the Taskbar would be
highlighted, I think u know what I mean... It's like the SFML Program don't want to loose his Focus and
don't want to go in the background, only after like 10-15 secs it gives up...

Yeah, its a strange a problem, but because I have at moment no other PC with Windows 7
I want to post this, so other people can maybe test it too.

BTW! Thats the reason why I maked recently a thread with question about the WinAPI, because
I try to use it and look if this solve the Problem and with connection of SFML and the WinAPI this
problem is really solved, it don't laggs by switching with Mouse and Taskbar if the SFML Window is in Foreground!

Thanks in Advance for helping!

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #1 on: May 12, 2012, 09:47:55 am »
Mhh.. No answeres?

A day before this Post I send a SFML test program to my friend, he has Windows 7 Home Premium and
telled me that he have the same problem, like I described before...

And this problem is very wiry, only if I combine SFML with WinAPI this problem is don't
existing anymore, but this costs the platform-independence and is anyway definitely not the best
way to solve this problem...

Still hoping for a solution...

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #2 on: May 12, 2012, 11:14:02 am »
Hello,
yeah, the Title is a little bit involved... The problem is, if I create a Window with
SFML and it is on the Foreground, it's lagging if I try to switch as example to Firefox,
with the Mouse and the Taskbar its lagging, with Alt + Tab not!

Mhh.. No answeres?

And this problem is very wiry, only if I combine SFML with WinAPI this problem is don't
existing anymore, but this costs the platform-independence and is anyway definitely not the best
way to solve this problem...

Still hoping for a solution...
I reason you got no reply is because I think all of us have no idea what your talking about. I couldn't see anything in that screenshot and saying your window is "lagging" could mean a lot of things. You need to provide some code and explain what you mean by combining SFML with WinAPI.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #3 on: May 12, 2012, 05:13:31 pm »
Ok, you are right, my explaining was maybe bad...  :-[

Ehm... I mean with combining SFML with WinAPI this -> http://www.sfml-dev.org/tutorials/1.5/graphics-win32.php

And the main Problem is that, if I open a SFML program, and go to taskbar ...
I make a Video, this is the best way to explain it perfectly!



You see, I start the test program, then I go with the Mouse over the task bar and it response
after some seconds, later I clicked on a task, and it goes in foreground
(depending on the program I clicked) after 3-5 seconds by bigger program's
like visual studio -> 5-8 seconds!

-> But with the Key Combination for switching the Window it works normally / perfect, without
any waiting!

Right clicking on a task
-> Seconds to show the Dialog for Closing the Window etc.! (forgot it in the Video, sorry)

After showing this, I showed the normal response time of the task's...

By making this Video, I noticed that there are strange Problem with Minimizing the program, too!
You can see it maybe in the Video how I "fight" with the Window! (Video: 0:30)

And I noticed that my recording program ONLY makes the "click" sound 1 second before the
clicked program goes in foreground, but in real I clicked seconds before, you can see it by the click
"Image" from the Screen Recorder... It seems that all programs have responsing problems after
bringing the SFML (without combination with WinAPI) program on the foreground or that the
"click" is processed very late... I hope the Video help's understanding the strange problem.

Maybe some of the Windows users that use SFML can test it too!
My friend tells me that with his low performance processer it's intolerable...
For me its still "tolerable", but it's interfere anyway...

EDIT:
Btw. the Source Code contains only the Render part (copy & paste from tutorial)
and 2 console outputs! Nothing else!
« Last Edit: May 12, 2012, 05:54:24 pm by Orezar »

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #4 on: May 13, 2012, 09:10:30 pm »
Still no one have an Idea what about I'm talking? ???

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #5 on: May 13, 2012, 09:28:05 pm »
What is the cpu usage of the test application when it is running? It sounds as if you are letting the test program run the render loop as fast as it can without any type of framerate limitation. Try limiting the framerate and see if it solves the problem.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #6 on: May 14, 2012, 12:32:50 am »
Quote
Btw. the Source Code contains only the Render part (copy & paste from tutorial)
and 2 console outputs! Nothing else!

Could you still provide the code please? Because I don't want to read though the tutorial to understand what's going on.

Also have you ever thought about that using WinAPI with SFML is maybe deapreciated. I mean you're using a tutorial for SFML 1.5, althought has changed since then.

The only reasonable explenation would be that the message queue gets spammed somehow...
Use a debugger and a profiler to figure out what's really going on.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #7 on: May 14, 2012, 03:08:05 am »
Quote
Btw. the Source Code contains only the Render part (copy & paste from tutorial)
and 2 console outputs! Nothing else!

Could you still provide the code please? Because I don't want to read though the tutorial to understand what's going on.

Also have you ever thought about that using WinAPI with SFML is maybe deapreciated. I mean you're using a tutorial for SFML 1.5, althought has changed since then.

The only reasonable explenation would be that the message queue gets spammed somehow...
Use a debugger and a profiler to figure out what's really going on.
First I agree with, please post your exact code.   ;)

Second thing is that the WinAPI with SFML will never be depreciated. That WinAPI code is exactly how you open a window in C++ regardless of whether or not you are using SFML. And for the message que, I can guarantee that it is correct. Without it your code will never ever receive a keyboard/mouse/window event message.

But please, OP post your code.
« Last Edit: May 14, 2012, 03:10:08 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #8 on: May 14, 2012, 03:55:51 pm »
Quote
What is the cpu usage of the test application when it is running? It sounds as if you are letting the test program run the render loop as fast as it can without any type of framerate limitation. Try limiting the framerate and see if it solves the problem.
The CPU Usage is between 1-7%, I think this is really normal / low...
I set the Framelimit on 30fps but for testing I setted it on 1fps, nothing changed, same problem!

Quote
The only reasonable explenation would be that the message queue gets spammed somehow...
Use a debugger and a profiler to figure out what's really going on.
This can be the reason, but I'm honest, I don't know how to see the message queue in...

The Code, how I written before, is really standard code:

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

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Framelimit
    App.setFramerateLimit(30);

    // Event
    sf::Event Event;

    std::cout << "...\n";
    std::cout << "...\n";

    while(App.isOpen())
    {
                while(App.pollEvent(Event))
                {
                        if(Event.type == sf::Event::Closed)
                        {
                                App.close();
                        }
                }

        App.clear();
        App.display();
    }

    return EXIT_SUCCESS;
}
 

...Yeah, thats it!

I am beginning to think that it's a problem with SFML...
However I'm going to test next time the same program with SFML 1.6
and look if there is the same problem!
« Last Edit: May 14, 2012, 04:12:22 pm by Laurent »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #9 on: May 14, 2012, 05:05:22 pm »
The Code, how I written before, is really standard code:

Why did you then say you've used some code from another old tutorial? ???

I'm using Win7 too and I don't experience anything like this for any SFML application.
Must either be on of your installed applications or hardware that doesn't do what you want. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #10 on: May 14, 2012, 06:58:22 pm »
Quote
Why did you then say you've used some code from another old tutorial?

I used the Code from the Tutorial, an add only a Framelimit, nothing more... :P

I send the Test program to another friend that was actually online, he has a bigger
problem... same code like posted before -> Can't open the Window, its minimzed, and
don't comes in the foreground... only the console is in the foreground, I was with teamviewer
on his desktop, and I can confirm it...

With a build that I get from a youtube Video description (yeah, I'm lazy), there was no problem, and
he can open the window without any problem... (But the problems I have, where in the Youtube Build too)

-> http://www.youtube.com/watch?v=cDNo4bzrFW8

Quote
I'm using Win7 too and I don't experience anything like this for any SFML application.

Have you test SFML 2.0 Application too and have you really made sure that it dont "laggs"?
« Last Edit: May 14, 2012, 07:00:04 pm by Orezar »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #11 on: May 15, 2012, 01:42:11 am »
I send the Test program to another friend that was actually online, he has a bigger
problem... same code like posted before -> Can't open the Window, its minimzed, and
don't comes in the foreground... only the console is in the foreground, I was with teamviewer
on his desktop, and I can confirm it...

I bet his screen resolution was smaller than the size of the window (either vertically or horizontally) the window then won't get displayed. I think Laurent will fix this, at least he stated this in another forum post.

I've looked at your video again and I see that you've changed your taskbar apperance to the old taskbar style. Does it lag too if you use the normal one?
Also is this caused by another application, because I couldn't find that option.

Have you test SFML 2.0 Application too and have you really made sure that it dont "laggs"?
That's what I was say...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Orezar

  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: [SFML 2.0] Strange Problem if Window is on Foreground!
« Reply #12 on: May 15, 2012, 08:05:20 pm »
Quote
I bet his screen resolution was smaller than the size of the window (either vertically or horizontally) the window then won't get displayed. I think Laurent will fix this, at least he stated this in another forum post.

You are right, this was the problem...

Quote
I've looked at your video again and I see that you've changed your taskbar apperance to the old taskbar style. Does it lag too if you use the normal one?
Also is this caused by another application, because I couldn't find that option.

I test it with the normal style, but same lagg problem...
My second friend test it now too, and he has no problems...

One friend and me has this problem, my second friend not! 2 vs 1...