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

Author Topic: Most random bug ever: old frame displaying occasionally  (Read 2735 times)

0 Members and 2 Guests are viewing this topic.

Daerst

  • Newbie
  • *
  • Posts: 12
    • View Profile
Most random bug ever: old frame displaying occasionally
« on: May 12, 2014, 12:41:24 pm »
Hey,

I've got a problem I can make absolutely no sense of. When my game is running, a seemingly random older frame (from the main menu, item selection, in-game state, whatever...) is popping up occasionally, every few minutes. I can't reproduce the bug, it occurs randomly whether I'm playing with lots of inputs and events going on or just standing around and watching the screen.

I use SFML.Net / C#, but I can't tell whether this problem might be related to the port.

The game loop looks like this, sparing some of the details:
while (Window.IsOpen() && _running)
{
    float time = GetTime();
    Window.Clear(Color.Black);
    Update(time);
    Draw();
    Window.Display();
    Window.DispatchEvents();
}

Nothing too unusual there, right? This is the only place in the code where the Display() function is called.

It seems to me that the GPU has some old frame stored that is randomly displayed. When using dual monitors, the 2nd screen goes black for a moment when this bug happens.

Any insights on why this is happening or how to fix this are appreciated. I've been gnawing at this bug for days.

Thanks,
David
« Last Edit: May 13, 2014, 11:19:36 am by Daerst »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Most random bug ever: old frame displaying occasionally
« Reply #1 on: May 12, 2014, 12:52:07 pm »
What's your OS? Graphics card? Version of SFML? Have you tried to reproduce it on other machines? Are your graphics drivers up-to-date?
Laurent Gomila - SFML developer

Daerst

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Most random bug ever: old frame displaying occasionally
« Reply #2 on: May 12, 2014, 01:04:31 pm »
Happens on both Windows 7 with NVidia GT540M and Windows 8.1 with some juicy AMD desktop card. We are using SFML.Net 2.1 with C# / MSVC 2012. Drivers are up to date on both machines.

The bug does not seem to happen in Window mode. To go into fullscreen, we use Mode = getDesktopMode() and either Fullscreen or None as a style (which as I understand it is the difference between true fullscreen and borderless window fullscreen). Both styles produce the error.
« Last Edit: May 12, 2014, 01:19:05 pm by Daerst »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Most random bug ever: old frame displaying occasionally
« Reply #3 on: May 12, 2014, 04:06:40 pm »
As always please write a complete and minimal example. I highly suspect this problem is not SFML's fault.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Daerst

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Most random bug ever: old frame displaying occasionally
« Reply #4 on: May 12, 2014, 07:05:32 pm »
Wish I could do that. I have no idea which part of my code causes the error, and I have no idea where to start debugging. I tried commenting out sections of my code and see if the error vanishes, but having to wait 5+ minutes just staring at the screen each time to see if the error occurs is pretty tiresome. Any tips on how to improve my example in this specific case?

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Most random bug ever: old frame displaying occasionally
« Reply #5 on: May 13, 2014, 10:44:01 am »
If you see an old frame the problem is most likely that under some circumstances you dont call Clear before calling Display.
Check that you dont have Display calls inside your Update/Draw, use a profiler to check if both are called the same number of times, then step through it with a debugger to see when it happens?

Btw., why are you calling Update twice?

Daerst

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Most random bug ever: old frame displaying occasionally
« Reply #6 on: May 13, 2014, 11:29:52 am »
The Display() call in the loop is the only one in the entire project. Update and Draw are called the same number of times, but I will check if this still holds true when the bug occurs.

Calling Update twice was an error not in the code, but in the stripped-down version I posted here. In the game code, Update is called only one. Sorry, I corrected it above :)

One thing I noticed: the bug does not seem to occur in Window mode (although I can never be sure, but I ran the game for about 15 minutes without problems). It appear in both Style=Fullscreen, VideoMode=getDesktopMode() and Style=None, VideoMode=getDesktopMode(). The way I understand it, the 'None' video mode is just borderless window, so it should behave just like the 'Default' mode, right? :-\

 

anything