Jump to content
  • Advertisement
Sign in to follow this  
pacifistcottage

Frame rate randomly locks at 48 FPS (PC)

This topic is 2476 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

Long-time lurker, but first-time poster. I am hoping someone can shed some light on an issue that is making me want to punch things.

Basically, one of the PCs on which I do XNA development is having frame rate issues, seemingly randomly. I am working on a 2d side-scrolling platformer kind of game, and sometimes, with no warning, the frame rate will suddenly just drop and lock to 48 FPS. So, a few important points:

  • When the game is running at 60FPS, Task Manager shows CPU usage at nearly nothing--between 1 and 3%. However, once the drop to 48 happens, CPU usage locks in at around 25%. Once it drops, it never goes back up. I just have to restart the game (sometimes it even does the 48 FPS thing immediately upon loading)
  • The level I am testing on is built from Tiled maps, and scripted. There is no random generation of anything going on, and everything should be more or less exactly the same every single time I play it, which is why I say this is happening randomly. It also happens at random times, not like, when loading new maps or creating enemies or anything
  • The PC I am working on is WAY overpowered to be having performance issues with this. It's not top of the line, but it's an i5, 8GB RAM, ATI 5770. I do plenty of gaming with pretty intensive games (not to mention other XNA games, like Terraria and Capsized) on it and it never breaks a sweat.
  • I can run the game on another machine, and it has no serious frame rate issues--usually sticks between 55 and 60 FPS (and it is a slower machine).
    I assumed I had made a mistake somewhere in my code and left a faulty loop running somewhere or something, but then I tested another developer's game on my machine, and the exact same thing happened. The game just throttled to 48 FPS. The fact that it happened in more than one game, both XNA, leads to believe something is amiss with my system, rather than my code.

    Is this anything anyone has ever heard of? I updated my graphics drivers, Win 7 64 is all up to date, A/V up to date, etc. I also tried disabling vsync, thinking maybe it was trying to lock to a defective monitor or something, but it made no difference. Any ideas?

    Could it be an IRQ issue, maybe with a wireless internet dongle or FireWire audio interface (admittedly, I don't know a whole lot about about how video cards deal with other system hardware)? It is driving me insane, when I am testing new code in my game and the frame rate just randomly drops.

    Any ideas would be appreciated. Thanks a bunch!

Share this post


Link to post
Share on other sites
Advertisement
How is it that when the game is at 60Fps, Task Manager shows 1-3% CPU usage? Seems to me you're using Sleep(). That's just wrong (because if you call Sleep(16) it will guarantee you it will sleep for A MINIMUM of 16 miliseconds; it may actually take more time).
And don't even think about calling Sleep(0); that's just worse.

Share this post


Link to post
Share on other sites

How is it that when the game is at 60Fps, Task Manager shows 1-3% CPU usage? Seems to me you're using Sleep(). That's just wrong (because if you call Sleep(16) it will guarantee you it will sleep for A MINIMUM of 16 miliseconds; it may actually take more time).
And don't even think about calling Sleep(0); that's just worse.


Nope, no calls to Sleep(), unless one of the XNA classes has calls to it built-in. None by me, though.

To clarify: I am fairly early in development, so there is not a whole lot going on the game (hence the low CPU usage), and these figures are based on doing nothing at all--just standing there. I guess, taking another look, it's more like 3-5% on average when not doing anything, but the point is it still jumps up the 48 FPS/25-ish%, as compared to 60 FPS/3-5%, so obviously something is wrong.

Typically, I wouldn't worry about performance this early in development, but as I said in my OP, it seems to be a system issue, rather than an issue with my code, because the same thing was happening in another game I tried.

Share this post


Link to post
Share on other sites

How is it that when the game is at 60Fps, Task Manager shows 1-3% CPU usage? Seems to me you're using Sleep(). That's just wrong (because if you call Sleep(16) it will guarantee you it will sleep for A MINIMUM of 16 miliseconds; it may actually take more time).
And don't even think about calling Sleep(0); that's just worse.


Vertical sync

Share this post


Link to post
Share on other sites
So here's a small update, and it makes me even more confused. Perhaps I am just misunderstanding XNA's Update/Draw hierarchy, but I am baffled. This is with IsFixedTimeStep set to false, and VSync set to true (but it doesn't change anything if I turn it off).

If I print gameTIme.ElapsedGameTIme to the Console during Update and Draw, it is showing a steady .0166667 every single frame, even when the game is running at 48/49 FPS. (I am using Fraps to display the FPS, but you can also visibly see that the game is running slower just by playing.)

So, maybe I am missing something obvious here. Why would it be running at 48/49 FPS when ElapsedGameTime is showing a consistent 16ms (i.e. 60 FPS)? For what it's worth, one sure-fire way to make the frame-rate drop is to click out of the game on another window and back into the game. This will make it happen every single time (although even if you don't do that, it still happens randomly while you're playing).

Share this post


Link to post
Share on other sites

This is with IsFixedTimeStep set to false, and VSync set to true (but it doesn't change anything if I turn it off).
[/quote]
VSync can often be "forced" on or off in the graphics driver. Open your graphics driver configuration screen, you may find a setting where you can change VSync to "application controlled", or just force it off temporarily while testing.

Share this post


Link to post
Share on other sites


This is with IsFixedTimeStep set to false, and VSync set to true (but it doesn't change anything if I turn it off).

VSync can often be "forced" on or off in the graphics driver. Open your graphics driver configuration screen, you may find a setting where you can change VSync to "application controlled", or just force it off temporarily while testing.
[/quote]

Ok, I will check that out. I looked briefly last night, but did not have enough time for a thorough check. That does seem like the kind of thing that is going on here, though. I'll report back once I get a chance to test it.

Thanks a bunch for the suggestion!

Share this post


Link to post
Share on other sites
It could be that something that happens during gameplay causes the game to become CPU bound (e.g. it starts doing an expensive calculation every frame). I'd suggest using a CPU profiler when it's running with the high CPU usage to find out if that's what is happening, and if so where.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!