Help optimizing an inconsistent framerate
I'm currently writing a relatively simple iphone game as my first attempt at writing software for the iphone/mac, and I'm running into some performance issues that I'm having a hard time solving. I'm trying to run my game at 60 FPS, and most of the time that's what it runs at. However, seemingly at random, a minority of the time I run the program it drops to 40 FPS, maybe 75% of the time I launch it, it runs smoothly, and 25% of the time it runs slow. The frame rate never varies once the app is launched, if it starts out at 60 FPS it stays at 60 FPS, and if it starts at 40 FPS it stays at 40 FPS. 40 is also a constant, it never runs at 35 or 45 or anything but 40 FPS or 60 FPS. Since I can't consistently reproduce this, I'm having a difficult time figuring out where to start looking for the problem. Has anyone seen anything like this before and could give me pointers of where I should be looking, so far I'm stumped and don't really know where to start.
What drives your drawing loop? NSTimer, CADisplayLink, something else?
It uses an NSTimer set to draw at 60 FPS. I used an opengl template that I found here as the starting template, and I haven't modified any of the timing code.
Hmm, I could have sworn I responded to this, but anyways, I'm using an NSTimer set to draw at a constant 60 FPS. Here's the template I started with that has all the loop code in it, I didn't modify that part.
Duddd Wrote:Hmm, I could have sworn I responded to this...
Yeah, sorry about that. We have to approve the first few posts of new members so we can weed out spammers. It's inconvenient but it's effective.
There was a whole bunch of discussion about this a while ago here, here, and here. It might be worth trying a timer with a shorter interval than 1 / 60, CADisplayLink, or a tight loop you drive yourself. If you create a new OpenGL ES project from the Xcode template, it includes CADisplayLink code you can use as an example.
Implementing the CADisplayLink to run the loop appears to have fixed the problem, thanks.
Possibly Related Threads...
|iPad,render to texture, low framerate||ldynasa||0||2,791||
Nov 13, 2010 12:34 AM
Last Post: ldynasa
|Optimizing my Game Engine. Help needed!||SamBaylus||25||16,800||
Feb 12, 2010 07:45 AM
Last Post: kae_
|Trying to save draw-calls for framerate (iphone app)||player___1||0||2,821||
Jul 6, 2009 12:39 PM
Last Post: player___1
|Much higher framerate when not debugging||monteboyd||6||3,279||
Feb 24, 2009 12:10 PM
Last Post: CarbonX
Oct 10, 2008 07:01 PM
Last Post: AnotherJake