This is also my biggest trouble with Unity Iphone. Stutters everywhere… 
The game suddenly pauses for some milliseconds and the objects “jump” when it resumes. This happens every 3-15 seconds, randomly. It doesn’t seem to be GC problem because I dont have an increasing heap. It seems to be the sensitivity of Unity to background OS processes. However this is disappointing for such simple scenes! It makes physics/animation useless…
This is a huge problem for a game which involves constant movement of objects for the whole gameplay session. Any stutter is very visible (especially with 60fps).
Below I am attaching a simple scene with 3 bouncing balls (meshes). I have tried every possible optimization I could find in the forums, with no success.
Unity team please help…
Some info:
On “Time” settings in player: have tried everything, left it with default (0.02, .0333, 1)
On appcontroller.mm: Loop=NSTimer with FPS=60 and throttle=1. Accelerometer frequency=1. (also tried other setups, NS seems the best here)
On device (iPhone 3G): Wifi, push notifications, bluetooth, location services, 3g = OFF
I have tested my app on a second device too (same results).
Typical Profile Stats:
iPhone Unity internal profiler stats:
cpu-player> min: 2.3 max: 7.4 avg: 3.7
cpu-ogles-drv> min: 0.7 max: 1.0 avg: 0.9
cpu-present> min: 6.4 max: 10.0 avg: 7.9
frametime> min: 14.4 max: 19.0 avg: 16.7
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.5 animation: 0.0 culling 0.3 skinning: 0.0 batching: 0.4 render: 1.6 fixed-update-count: 0 .. 1
mono-scripts> update: 0.0 fixedUpdate: 0.3 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 0.7 max: 8.6 avg: 4.6
cpu-ogles-drv> min: 0.4 max: 4.2 avg: 1.2
cpu-present> min: 1.0 max: 7.8 avg: 1.5
frametime> min: 13.2 max: 35.3 avg: 17.5
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.4 animation: 0.0 culling 0.5 skinning: 0.0 batching: 0.6 render: 2.2 fixed-update-count: 0 .. 1
mono-scripts> update: 0.0 fixedUpdate: 0.3 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: -1.4 max: 9.0 avg: 4.5
cpu-ogles-drv> min: 0.6 max: 4.8 avg: 1.3
cpu-present> min: 1.2 max: 3.4 avg: 1.3
frametime> min: 14.4 max: 18.2 avg: 16.7
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.3 animation: 0.0 culling 0.5 skinning: 0.0 batching: 0.7 render: 2.4 fixed-update-count: 0 .. 1
mono-scripts> update: 0.0 fixedUpdate: 0.2 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
and other times…
iPhone Unity internal profiler stats:
cpu-player> min: 0.4 max: 6.7 avg: 3.8
cpu-ogles-drv> min: 0.7 max: 2.8 avg: 1.0
cpu-present> min: 1.3 max: 6.1 avg: 3.8
frametime> min: 14.4 max: 18.5 avg: 16.7
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.3 animation: 0.0 culling 0.4 skinning: 0.0 batching: 0.5 render: 1.7 fixed-update-count: 0 .. 1
mono-scripts> update: 0.0 fixedUpdate: 0.2 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 2.5 max: 11.9 avg: 4.4
cpu-ogles-drv> min: 0.4 max: 1.1 avg: 0.8
cpu-present> min: 1.1 max: 5.4 avg: 3.6
frametime> min: 14.0 max: 87.4 avg: 19.5
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.5 animation: 0.0 culling 0.5 skinning: 0.0 batching: 0.5 render: 1.9 fixed-update-count: 0 .. 2
mono-scripts> update: 0.0 fixedUpdate: 0.5 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player> min: 2.2 max: 6.8 avg: 3.6
cpu-ogles-drv> min: 0.7 max: 1.1 avg: 0.8
cpu-present> min: 2.8 max: 6.4 avg: 4.4
frametime> min: 14.4 max: 18.9 avg: 16.6
draw-call #> min: 2 max: 2 avg: 2 | batched: 7
tris #> min: 1612 max: 1612 avg: 1612 | batched: 1612
verts #> min: 918 max: 918 avg: 918 | batched: 918
player-detail> physx: 0.3 animation: 0.0 culling 0.4 skinning: 0.0 batching: 0.4 render: 1.8 fixed-update-count: 0 .. 1
mono-scripts> update: 0.0 fixedUpdate: 0.2 coroutines: 0.0
mono-memory> used heap: 126976 allocated heap: 1089536 max number of collections: 0 collection total duration: 0.0
I have found that 3 things can help a bit, but are not enough to eliminate the stutter:
- Run the game with the device unplugged!
- After a Unity “Build Run” go to XCode, change something minor in appcontroller.mm , save the file and then just “Go” (click continue to the error message). Seems to be pure voodoo, but it partially works for a reason.
- Set device to Airport mode. This makes the biggest difference (-60% of stutters).
However, all the above are things the developer cannot ask from the player to do…
I am attaching the scene that gave the results above. However, the same problem exists even for the simplest scene (even with just a camera).
Please help…
279126–9999–$stutters_100.unitypackage (35.2 KB)