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

Author Topic: [Solved] Mysterious Regular Frame Stutter  (Read 4739 times)

0 Members and 1 Guest are viewing this topic.

hutty

  • Newbie
  • *
  • Posts: 6
    • View Profile
[Solved] Mysterious Regular Frame Stutter
« on: September 22, 2016, 08:18:07 pm »
Hello, I've been working on a rather large project for a while now, recently i've been fixing various performance issues and have come across one that I cannot fix.

The framerate seems to stutter, like every second one of the frames takes 3x as long as usual. As you could imagine, it makes the game feel very laggy even though its supposedly running above 120 fps.

In this image you can see gaps in the trail (one dot for each physics tick) left behind the player due to the stuttering.


Here I made some charts showing the stuttering
https://docs.google.com/spreadsheets/d/1xhJ4jbfifPfdcIPZsKiU_f0-IVT453xlORrHtwMfyLQ/edit?usp=sharing

The most disturbing part, is the stutters seem to exist in the green-circle tutorial.

I am using SFML 2.1, codeblocks with the GCC compiler, on windows 8.1 (more info at bottom of post)
Other games run smoothly, so this is not a system wide issue.

Things I have tried
   *I have already tried every combination of framerate limit and vsync, before that gets inevitably mentioned.
   *There is not visible difference between a debug build and a release build.
   *Rendering to a window directly instead of a render texture (not a permanent solution anyways because i need that texture to scale the game down for smaller resolutions)
   *Strategically positioning the clear() command in many different places, including the correct one.

Things I have not tried:
  *SFML 2.4, i cant get it to work due to (what I assume) is a compiler missmatch, which i cant fix because there is no way for me to find out what version of GCC I am using (as far as I know)
  *Other compilers, visual studio is 9 gigs, that would take a week to download with my internet
  *Other operating systems, i don't have a working linux partition at the moment, and the only mac I have available is running 10.4  I have confirmed the bug happens on windows 8.0 and windows 8.1



Here is a link to a zip of my full project. You should be able to simply open it up (the project file is called Ambure) in codeblocks and hit compile. (the blue refreshy compile, not the normal yellow gear one)

To control the player (it spawns invisible), press space and then move around with the arrow keys.
Press the home button on your keyboard to access the devtools if you want to mess around with the engine.

The frametime is dumped to the console, the cout statement for that is in main.cpp

Link to Full Project .zip
https://drive.google.com/file/d/0B16tFq7OKBQzZ3Yxd2JwWDhMeGM/view?usp=sharing



Link to project Devlog of the Project
https://forums.tigsource.com/index.php?topic=57907.0

More system information:
http://imgur.com/bk0Ow1p
http://paste.ubuntu.com/23216796/

Similar posts I have found that may be related but do not help me solve the problem
http://gamedev.stackexchange.com/questions/67212/why-do-i-have-to-run-my-2d-game-at-300-fps-for-movement-to-be-passably-smooth
http://en.sfml-dev.org/forums/index.php?topic=6854.0

I hope that is enough information.
« Last Edit: September 25, 2016, 04:49:39 am by hutty »

hutty

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Mysterious Regular Frame Stutter
« Reply #1 on: September 23, 2016, 12:13:17 am »
I have been trying other SFML made games on my computer, and they all lack the stutter issue. Which leads me to believe the issue is either with my specific SFML version, or GCC.

CptnRoughnight

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Mysterious Regular Frame Stutter
« Reply #2 on: September 23, 2016, 09:18:00 am »
Hi,

I've got the same behavior by using deWiTTERS Gameloop without implementing the interpolation. Maybe there's a time offset between update- and drawing methods.

regards
I am Cptn. Ferdinand Darth Roughnight Timelord of the ancient Enterprise Earl of Tatooine.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Mysterious Regular Frame Stutter
« Reply #3 on: September 23, 2016, 10:23:43 am »
Go to the Nvidia Control Panel and disable "Multithreaded Optimization". See if that changes anything.

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Mysterious Regular Frame Stutter
« Reply #4 on: September 23, 2016, 10:43:00 am »
Go to the Nvidia Control Panel and disable "Threaded Optimization". See if that changes anything.

I was having the same problem so I tried this on my work machine (I'd not heard of it before) and it did the trick.

hutty

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Mysterious Regular Frame Stutter
« Reply #5 on: September 23, 2016, 03:40:58 pm »
Thanks, it appears that works.

Although that leads to another problem, because It wouldn't be nice to need to tell everyone who plays my game to turn off a setting in their nvidea control panel. Is there a proper way to set it to off while the game is running, or make some change so it does not conflict with the setting?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Mysterious Regular Frame Stutter
« Reply #6 on: September 24, 2016, 09:48:30 pm »
In theory you could create a profile for your game, but that's no perfect solution either. I still couldn't find the actual reason for this behavior. It might have something to do with how SFML handles the OpenGL context, but then again I've seen other (SDL based) games having the very same problem.

Edit: As for the profile, see this question and answer on Stack Overflow.

hutty

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Mysterious Regular Frame Stutter
« Reply #7 on: September 25, 2016, 04:49:19 am »
Thanks again, you've been a real lifesaver.

 

anything