Help optimizing an inconsistent framerate

Apprentice
Posts: 5
Joined: 2010.02
Post: #1
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.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
What drives your drawing loop? NSTimer, CADisplayLink, something else?
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2010.02
Post: #3
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.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2010.02
Post: #4
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.

http://iphonedevelopment.blogspot.com/20...oject.html
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #5
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.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #6
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.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2010.02
Post: #7
Implementing the CADisplayLink to run the loop appears to have fixed the problem, thanks.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPad,render to texture, low framerate ldynasa 0 2,587 Nov 13, 2010 12:34 AM
Last Post: ldynasa
  Optimizing my Game Engine. Help needed! SamBaylus 25 15,606 Feb 12, 2010 07:45 AM
Last Post: kae_
  Trying to save draw-calls for framerate (iphone app) player___1 0 2,663 Jul 6, 2009 12:39 PM
Last Post: player___1
  Much higher framerate when not debugging monteboyd 6 3,119 Feb 24, 2009 12:10 PM
Last Post: CarbonX
  Optimizing Vertices bmantzey 8 3,908 Oct 10, 2008 07:01 PM
Last Post: AnotherJake