Reputation: 3126
I have an NSTimer that runs at 60hz. With an OpenGL scene loaded and rendering, my game can get 60fps, solid, all day long.. Then if I go and recompile the app, or reload it, it will get 40fps. Same resources loaded. I've been running into this problem for years, and I just want to know why. It's crazy, and I want to know if I should just abandon this stupid Timer. Conditions are not different on my 3GS between loads. It will just get 40fps sometimes. Obviously the clockrate is not different between loads, so the performance figures should be constant given a constant scene. Here is a log of my framerates:
A good load: :-)
FrameRate: 61 FrameRate: 61 FrameRate: 61 FrameRate: 60 FrameRate: 60 FrameRate: 61 FrameRate: 60 FrameRate: 60 FrameRate: 61 FrameRate: 60 FrameRate: 61
Now, I'll go ahead and do nothing, recompile, and run:
FrameRate: 43 FrameRate: 50 FrameRate: 45 FrameRate: 48 FrameRate: 40 FrameRate: 45 FrameRate: 42 FrameRate: 41 FrameRate: 42 FrameRate: 44 FrameRate: 41 FrameRate: 46
^- Massive difference visually. What the flying heck could cause this?
SAME area of the scene, SAME camera setup. No variables are different.
[Edit] Some have mentioned that the music not running in the hardware decoder can cause this, and that sometimes the decoder will NOT take over even if you set it up to. However, I can say that even with music disabled, this happens [/Edit]
Upvotes: 2
Views: 552
Reputation: 36389
Have you tried using CADisplayLink
instead? From the documentation:
A CADisplayLink object is a timer object that allows your application to synchronize its drawing to the refresh rate of the display.
...
Once the display link is associated with a run loop, the selector on the target is called when the screen’s contents need to be updated.
I haven't used it personally, but it looks like it might help any issues you have with the lower frame rate, even if it doesn't increase your frame rate per se.
Upvotes: 2