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

Author Topic: SDL->SFML conversion; very strange performance issues  (Read 16387 times)

0 Members and 1 Guest are viewing this topic.

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
SDL->SFML conversion; very strange performance issues
« Reply #30 on: January 18, 2012, 08:51:37 pm »
I've sugested once to put this function on a different thread and call it again when completed... Is there any reason to not do that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SDL->SFML conversion; very strange performance issues
« Reply #31 on: January 18, 2012, 10:57:43 pm »
I don't know, I haven't really thought about potential solutions. I'm afraid it will happen only in SFML 2.1.
Laurent Gomila - SFML developer

Serapth

  • Full Member
  • ***
  • Posts: 105
    • View Profile
SDL->SFML conversion; very strange performance issues
« Reply #32 on: January 19, 2012, 01:13:53 am »
I tried to replicate the problem and had some success.


I got it to go from >1000 + FPS, plugged in my 360 wireless receiver, nothing happened, turned on the gamepad and a few seconds later, FPS dropped to 20ish, but then it jumped right back up to 1000+ and I haven't been able to get the framerate to drop like that again.

If I can make it 100% replicable, I will try to bug hunt it, but this intermittent stuff... that's irritating.  Is there a way to make this 100% reproducable?


Right now I used:



Code: [Select]
int _tmain(int argc, _TCHAR* argv[])
{
sf::Window app = sf::Window(sf::VideoMode(800,600,32),"test");

sf::Event event;
for(;;)
{
        while (app.PollEvent(event))
        {
            if (event.Type == sf::Event::Closed)
                app.Close();

            if (event.Type == sf::Event::KeyPressed)
            {
                if (event.Key.Code == sf::Keyboard::Key::Escape)
                    app.Close();
            }        
}

sf::Uint32 elapsedTime = app.GetFrameTime();

if(elapsedTime == 0.0f) app.SetTitle("Lots");
else
{
std::ostringstream ost;
ost << 1000.f / elapsedTime;
app.SetTitle(ost.str());
}
app.Display();
}
}



That should be sufficient to cause the problem, right?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SDL->SFML conversion; very strange performance issues
« Reply #33 on: January 19, 2012, 07:56:56 am »
Quote
Is there a way to make this 100% reproducable?

It seems to be really random. Sometimes it happens just once, after plugging/unplugging a joystick, and then disappears the next time without changing anything.
Laurent Gomila - SFML developer

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
SDL->SFML conversion; very strange performance issues
« Reply #34 on: January 19, 2012, 09:28:19 am »
A friend of mine also experienced the joystick/FPS drop problem in SFML2 and suggested I change the line 81 in JoystickManager.cpp from
 JoystickImpl::IsConnected(i))
to
 if (myConnectCheck++ % 5000 == 0) JoystickImpl::IsConnected(i))

and add a private unsigned int variable "myConnectCheck" to JoystickManager.hpp. The number "5000" above is somewhat "hackish" though, as it seems to depend on the framerate I think.

Is this a valid suggestion/"hack" for the time being? I did not experience the issue myself yet (no joystick :-) ), but I want to prepared.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SDL->SFML conversion; very strange performance issues
« Reply #35 on: January 19, 2012, 09:46:45 am »
It's very ugly and 5000 is too high (at 60 FP you'll check joysticks every 83 seconds). But it should be ok.
Laurent Gomila - SFML developer

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
SDL->SFML conversion; very strange performance issues
« Reply #36 on: January 19, 2012, 10:00:22 am »
Quote from: "Laurent"
It's very ugly and 5000 is too high (at 60 FP you'll check joysticks every 83 seconds). But it should be ok.

Ok, maybe I wait for a better "official" solution and let the regular SFML libraries as they are now - at least until I have a project worth releasing, and worry about the problem then :)