At first I used NSTimer and ran into the problem of the frame rate being stuck at 40 frames per second. I've read about using CADisplayLink to fix the problem. It seemed to work for a while, but recently, the app starts at 60, then after a little while (about 5 - 20 seconds in) the app starts to run at 40 - 41 fps and gets stuck there. And I'm culling so that there's less draws when objects are out of view, but yet it stays stuck there. A unusual way that does seem to remedy the problem for a moment (about 10 seconds) is to disconnect the wire from the bottom of the iphone and then connect it again. Obviously, this is not ideal, but just wondering why does this happen and why does it somewhat fix it, as if it resets certain values or something. ANY help will be greatly appreciated, thanks.
-
What are you doing at, after or between each CADisplayLink render call? An OpenGL or drawRect render? Reading any pixels? Getting any UI callbacks? Audio? Some of these can stall the hardware graphics pipeline for a refresh cycle or otherwise cause missed or dropped frames. – hotpaw2 Jan 01 '11 at 19:41
3 Answers
Have you checked to see whether you're actually dropping frames? Are you using the CPU/GPU to the extent that you can only draw 40 frames in a second, or is the problem somewhere in the software?
Remember that if a CADisplayLink
is unable to fire for a screen refresh (due to the main thread being busy doing things like drawing the previous frame) then it may skip it, as it won't have enough time to complete. So if some of your frames take more than 0.01666... seconds to draw, you'll miss the interval to draw the frames right after, and the slowdown may appear worse than it is.
Also remember that a mobile device is not always capable of drawing everything quickly. The A4 processor in an iPhone 4 is very good, but it's still a tall order to fill 960x640 screen pixels 60 times a second. The vast majority of your users will not notice if your frame rate is 40fps instead of 60fps--the human eye doesn't generally notice judder or screen lag until you're around 20fps and lower.

- 43,286
- 8
- 74
- 104
-
I understand there's slowdown when there's a lot of draws and other things going on, but what's strange is when there's fewer draws and other operations, the frame rate never catches up. (kind of like the NSTimer frame rate issues people were having). I'm using Opengl btw. I'm going to try a couple of workarounds, I'll post if I find anything – avide Jan 02 '11 at 19:00
I have got the same issue on 3G. I have simplified my app just to FPS counter drawn over the blank (pink) backbuffer and it was 40 fps nevertheless.
After some googling I have found a very similar issue being discussed at cocos2d-iphone.org forum.
The solution was to turn off autorotation of the view controller. So i made my shouldAutorotateToInterfaceOrientation always return NO and this worked (!!!). I had stable 60 FPS. Then I returned my simple game graphics back and it was stable 60 FPS. But my game expected to run in the landscape mode is currently running in default portrait mode.
I have no desire to write my own autorotation code so looks like I am switching back to 40 fps. Does anybody know how to avoid this autorotation framerate drop?

- 782
- 1
- 8
- 19
-
1I remember reading somewhere in the Apple docs that, if you do autorotation on OpenGL ES apps, you should roll 'your own' rotation of the screen using gl transforms rather than relying on UIViewController's functionality, to achieve better performance... – Nicolas Miari Jun 21 '12 at 21:40
Same problem here. I have a very basic openGL view (rotating cube), it starts at 60fps, once I run a heavy task to slow it down a bit, it never come bacl to 60fps after and its stick at a steady 40fps. I'm using CADisplayLink, and its just running on a test app doing basically nothing that experimenting with this issue :/
If someone have a solution, I would be really grateful.

- 11
- 1