Ipad Performance Issue

I have a level in my 2.5D platformer that is having poor performance on Ipad3. The game is basically a player character that fights waves of enemies. I have the data from the iphone profiler below comparing a level that is running nicely compared to the problem level, Level A and B respectively. Both levels use the Mobile/Particle/Alpha Blended shader as a transparent shader, and a mobile/diffuse shader for the background. There are overlapping shaders in both levels, I read this could be an issue. I am confused why I am getting poor performance on one level because these levels are very similar, Level B is slightly more complex but the performance is unplayable. The weird thing is that even without any enemies spawning, in Level B the performance is still way more jittery than Level A, and Level A has enemies spawning! What could be causing this? Not sure if it is code or texture/shader/geometry. Here is the data:

LEVEL A

Textures/Shaders:

13 Mobile/Particle/Alpha Blended shaders, with textures ranging from 256 to 512, with one 1024.
1 Mobile/Diffuse 2048
All textures are compressed for Iphone

LEVEL A - With Enemies running nicely

iPhone Unity internal profiler stats:
cpu-player> min: 12.4 max: 17.3 avg: 13.8
cpu-ogles-drv> min: 1.9 max: 2.6 avg: 2.1
frametime> min: 32.5 max: 34.2 avg: 33.3
draw-call #> min: 32 max: 32 avg: 32 | batched: 4
tris #> min: 9522 max: 9528 avg: 9524 | batched: 960
verts #> min: 10280 max: 10292 avg: 10285 | batched: 484
player-detail> physx: 4.8 animation: 0.6 culling 0.0 skinning: 2.8 batching: 0.2 render: 2.1 fixed-update-count: 3 … 4
mono-scripts> update: 2.1 fixedUpdate: 0.0 coroutines: 0.1
mono-memory> used heap: 458752 allocated heap: 487424 max number of collections: 4 collection total duration: 10.2

LEVEL B

Textures/Shaders:

15 Mobile/Particle/Alpha Blended shaders, with textures ranging from 256 to 512, with TWO 1024.
1 Mobile/Diffuse 2048
All textures are compressed for Iphone

LEVEL B - No Enemies (Running poorly/jittery)

iPhone Unity internal profiler stats:
cpu-player> min: 45.2 max: 56.7 avg: 51.1
cpu-ogles-drv> min: 0.9 max: 1.3 avg: 1.0
frametime> min: 48.5 max: 60.8 avg: 54.7
draw-call #> min: 24 max: 24 avg: 24 | batched: 6
tris #> min: 4486 max: 4494 avg: 4489 | batched: 1440
verts #> min: 3309 max: 3325 avg: 3315 | batched: 726
player-detail> physx: 46.9 animation: 0.2 culling 0.0 skinning: 0.3 batching: 0.3 render: 1.2 fixed-update-count: 5 … 6
mono-scripts> update: 0.8 fixedUpdate: 0.0 coroutines: 0.1
mono-memory> used heap: 344064 allocated heap: 487424 max number of collections: 75 collection total duration: 153.1

→ applicationWillResignActive()
→ applicationDidEnterBackground()

LEVEL B - With Enemies (Unplayable)

iPhone Unity internal profiler stats:
cpu-player> min: 55.8 max: 361.1 avg: 177.6
cpu-ogles-drv> min: 1.7 max: 23.9 avg: 3.2
frametime> min: 60.3 max: 368.8 avg: 184.4
draw-call #> min: 32 max: 45 avg: 36 | batched: 6
tris #> min: 8238 max: 13568 avg: 10996 | batched: 1440
verts #> min: 8421 max: 15434 avg: 11966 | batched: 726
player-detail> physx: 164.6 animation: 2.2 culling 0.0 skinning: 2.9 batching: 0.3 render: 2.1 fixed-update-count: 6 … 34
mono-scripts> update: 2.6 fixedUpdate: 0.0 coroutines: 0.8
mono-memory> used heap: 380928 allocated heap: 487424 max number of collections: 281 collection total duration: 560.6

The profiler thinks it’s phusics’ fault. If you take a look at “player-detail> physx:” you’ll notice that it’s 4,8 ms on Level A and 46,9 ms on an empty Level B (even more with enemies). Lots of things could be wrong with physics. Perhaps a large number of static colliders is moving in the scene… Hard to guess without seeing the level.

Best regards,
Peter.

Yea I was looking at that. Well I dont have any static colliders moving, and the player and enemies are the same for both levels. Could it be something in my code affecting the physx? What does frametime point to? I see that is very high too. Thanks very much for the reply

Frametime is basically combined time of all the tasks from player-detail and mono-scripts you see at the bottom of the log. Could something from a script cause it? Obviously, but I imagine it would be fairly easy to spot with that much impact on the performance. You can try running remote profiler to get some more speciffic information on what makes physics stutter so much.

Best regards,
Peter.

I think I have found the issue, or atleast a large part of the issue. I had a lot of rigidbodies on static objects that did not need to be there and were not setup correctly. After removing them performance drastically improved. It is still not great but it is playable. Thanks for your help

It’s the 281 collections (that’s garbage collection) which used 560 ms which should be your next target.

I honestly don’t know what that means, do you feel like elaborating because I am interested. I see the numbers you’re talking about but I don’t know what they actually mean.

You need to profile with Unity on the device over wi-fi, on Android it gives you deep information on the main thread. Maybe mono memory is from scripts? The number is really high.

Deep profiling and see what script is causing the error maybe?

Best,