- Home /
iOS framerate drops every 10 seconds or so...
I have an extremely simple project - 1 directional light, 1 cube with Default-Diffuse material on it and 1 camera. Camera points at cube and cube has the following script on it:
void Update () {
transform.Rotate(0, Time.deltaTime*10, Time.deltaTime*20);
}
That's all there is to it... Deploying to iOS, I get a nicely spinning cube as expected... But every 10 seconds or so, it gets choppy - skipping a handful of frames. Since there is almost nothing going on, I am guessing that either there are background processes in Unity messing things up or the OS itself is doing something that prevents smooth consistent animation.
Here is the relevant profiler output...
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 1.1 max: 2.9 avg: 1.4
cpu-ogles-drv> min: 0.1 max: 0.3 avg: 0.1
frametime> min: 27.3 max: 38.4 avg: 33.4
draw-call #> min: 1 max: 1 avg: 1 | batched: 0
tris #> min: 12 max: 12 avg: 12 | batched: 0
verts #> min: 24 max: 24 avg: 24 | batched: 0
player-detail> physx: 0.4 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: -1.0 fixed-update-count: 1 .. 2
mono-scripts> update: 0.1 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 188416 allocated heap: 200704 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 1.2 max: 3.8 avg: 1.5
cpu-ogles-drv> min: 0.1 max: 0.6 avg: 0.1
frametime> min: 26.3 max: 207.8 avg: 38.9
draw-call #> min: 1 max: 1 avg: 1 | batched: 0
tris #> min: 12 max: 12 avg: 12 | batched: 0
verts #> min: 24 max: 24 avg: 24 | batched: 0
player-detail> physx: 0.4 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: -0.9 fixed-update-count: 1 .. 10
mono-scripts> update: 0.1 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 188416 allocated heap: 200704 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 1.2 max: 2.9 avg: 1.5
cpu-ogles-drv> min: 0.1 max: 0.1 avg: 0.1
frametime> min: 20.0 max: 138.8 avg: 38.3
draw-call #> min: 1 max: 1 avg: 1 | batched: 0
tris #> min: 12 max: 12 avg: 12 | batched: 0
verts #> min: 24 max: 24 avg: 24 | batched: 0
player-detail> physx: 0.4 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: -0.9 fixed-update-count: 1 .. 7
mono-scripts> update: 0.1 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 188416 allocated heap: 200704 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 1.1 max: 2.3 avg: 1.3
cpu-ogles-drv> min: 0.1 max: 0.1 avg: 0.1
frametime> min: 29.0 max: 38.1 avg: 33.4
draw-call #> min: 1 max: 1 avg: 1 | batched: 0
tris #> min: 12 max: 12 avg: 12 | batched: 0
verts #> min: 24 max: 24 avg: 24 | batched: 0
player-detail> physx: 0.4 animation: 0.0 culling 0.0 skinning: 0.0 batching: 0.0 render: -1.1 fixed-update-count: 1 .. 2
mono-scripts> update: 0.1 fixedUpdate: 0.0 coroutines: 0.0
mono-memory> used heap: 188416 allocated heap: 200704 max number of collections: 0 collection total duration: 0.0
----------------------------------------
The first set of stats is what you'd expect, but in the second the frametime max is 207.8 ms - a full 1/5th of a second - a very noticable pause in the animation. The third set of stats again has a slow frame at 138.8 ms. At the fourth, everything is back to normal again and it will continue that way for another 10 seconds or so.
Is everyone else seeing this also? I'm using Unity Pro with Unity iOS (not iOS Pro) deploying to an iPhone 4. I get this even if I reboot the iPhone and ensure no other apps are running. Haven't tried resetting my iPhone to factory defaults yet, but I am hoping that there is indeed something unique to my phone and this is not a real problem.
Thanks for reading - any experience you can share this issue (or lack thereof if you've never seen it) would be appreciated.
It's not something that I have seen before. Probably worth trying a different device. $$anonymous$$aybe your phone is running some other application that needs some CPU time.
Yes, that was my thought. Good to hear that you've not seen this. :)
Answer by hvilela · Oct 11, 2012 at 06:31 PM
My guess it that you are allocating too much, giving too much work to the garbage collector. Could be this the cause of your problem?
GC is very slow on iPhone and Unity GC apparently does not apply generations, it does the lot.
Thanks for the feedback... I'm going to try another device...
There is no allocation whatsoever... The only scripting code in the project is the one line above that rotates the cube. So, the GC should not be doing anything... Nothing is ever created.
Glad to hear that others are not seeing this problem - hopefully it's just my device.
Sorry to bump this but I get the same behaviour, on ALL of my iDevices. Did you ever find a fix? It REALLY kills my game...
Your answer
Follow this Question
Related Questions
Is iOS hardware always locked at 60hz? 1 Answer
iOS profiling help 0 Answers
iOS VSync always active? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers