Hello Guest

Author Topic: iOS Performance w/ Multiple Animated Sprites  (Read 4836 times)

Arktor314

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
iOS Performance w/ Multiple Animated Sprites
« on: June 25, 2013, 07:29:34 am »
My RTS-like game is experiencing bad performance hits after around 20-30 animated sprites are on the screen at once. From the profiler (below), it looks like most of the performance hit is being caused by Draw calls. I already have the terrain in Static Sprite Batchers - is there a way for me to more efficiently render 20-30 different animated sprites (composed of, 4-8 different sprite collections) that won't bomb performance?


Code: [Select]
Phone Unity internal profiler stats:
cpu-player>    min: 14.0   max: 10947.3   avg: 532.5
cpu-ogles-drv> min:  2.3   max:  9.4   avg:  3.9
cpu-present>   min:  0.9   max: 16.5   avg:  4.4
cpu-waits-gpu> min:  0.9   max: 16.5   avg:  4.4
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 19.3   max: 10983.1   avg: 546.7
draw-call #>   min:  31    max:  43    avg:  37     | batched:    19
tris #>        min:  1297  max:  1405  avg:  1351   | batched:   134
verts #>       min:  1874  max:  2118  avg:  1997   | batched:   384
player-detail> physx:  6.2 animation:  0.0 culling  0.0 skinning:  0.0 batching:  1.3 render: 18.7 fixed-update-count: 0 .. 30
mono-scripts>  update: 150.0   fixedUpdate: 119.6 coroutines: 14.7
mono-memory>   used heap: 5124096 allocated heap: 8425472  max number of collections: 12 collection total duration: 433.5
« Last Edit: June 25, 2013, 09:04:39 am by Arktor314 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: iOS Performance w/ Multiple Animated Sprites
« Reply #1 on: June 25, 2013, 12:40:20 pm »
WHat happens if you turn off the animators, what is performance like then? Also, what device are you running on? I wouldn't consider 30 to be a large number for animated sprites - your cpu player stats are suspiciously high, so run this through the Unity profiler for more details on what going on. Sadly the profiler stats below don't give much information, you will need to get some stats from the Unity profiler.

Edit: Also, how many animated sprites do you have, which are out of view?

Arktor314

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: iOS Performance w/ Multiple Animated Sprites
« Reply #2 on: June 25, 2013, 11:58:31 pm »
Disabling animators didn't have an impact. The cpu player there is a little high because I probably took that right after the game was saved or loaded. I took a few more for a better picture:

Game started:
Code: [Select]
iPhone Unity internal profiler stats:
cpu-player>    min:  7.5   max: 33.0   avg: 12.5
cpu-ogles-drv> min:  1.9   max:  8.1   avg:  3.5
cpu-present>   min:  0.9   max:  5.3   avg:  2.2
cpu-waits-gpu> min:  0.9   max:  5.3   avg:  2.2
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 16.9   max: 50.8   avg: 33.4
draw-call #>   min:  27    max:  32    avg:  30     | batched:     6
tris #>        min:  1352  max:  1462  avg:  1421   | batched:   278
verts #>       min:  1997  max:  2237  avg:  2149   | batched:   557
player-detail> physx:  0.3 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.7 render:  9.0 fixed-update-count: 0 .. 2
mono-scripts>  update:  0.5   fixedUpdate:  0.7 coroutines:  0.0
mono-memory>   used heap: 3923968 allocated heap: 4452352  max number of collections: 0 collection total duration:  0.0

Later in game:
Code: [Select]
iPhone Unity internal profiler stats:
cpu-player>    min: 39.9   max: 130.2   avg: 59.5
cpu-ogles-drv> min:  2.0   max:  5.9   avg:  2.9
cpu-present>   min:  1.0   max: 10.1   avg:  3.2
cpu-waits-gpu> min:  1.0   max: 10.1   avg:  3.2
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 46.1   max: 140.7   avg: 68.6
draw-call #>   min:  30    max:  33    avg:  31     | batched:    25
tris #>        min:  1341  max:  1343  avg:  1341   | batched:   237
verts #>       min:  2014  max:  2018  avg:  2015   | batched:   479
player-detail> physx:  0.7 animation:  0.0 culling  0.0 skinning:  0.0 batching:  1.2 render: 16.3 fixed-update-count: 2 .. 7
mono-scripts>  update:  0.5   fixedUpdate: 38.7 coroutines:  1.0
mono-memory>   used heap: 7016448 allocated heap: 11796480  max number of collections: 0 collection total duration:  0.0

Even later...
Code: [Select]
iPhone Unity internal profiler stats:
cpu-player>    min: 50.2   max: 85.1   avg: 66.5
cpu-ogles-drv> min:  2.2   max:  6.1   avg:  3.1
cpu-present>   min:  1.0   max:  9.6   avg:  2.9
cpu-waits-gpu> min:  1.0   max:  9.6   avg:  2.9
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 57.4   max: 105.3   avg: 75.7
draw-call #>   min:  35    max:  35    avg:  35     | batched:    28
tris #>        min:  1349  max:  1355  avg:  1352   | batched:   243
verts #>       min:  2030  max:  2042  avg:  2036   | batched:   490
player-detail> physx:  0.7 animation:  0.0 culling  0.0 skinning:  0.0 batching:  1.2 render: 16.9 fixed-update-count: 3 .. 5
mono-scripts>  update:  0.5   fixedUpdate: 47.0 coroutines:  0.0
mono-memory>   used heap: 6737920 allocated heap: 11829248  max number of collections: 0 collection total duration:  0.0

It looks like you might be right about the issue being with cpu-player.
« Last Edit: June 26, 2013, 12:09:55 am by Arktor314 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: iOS Performance w/ Multiple Animated Sprites
« Reply #3 on: June 26, 2013, 09:54:08 am »
You should run this through the Unity Profiler (i.e. the one you get with Unity Pro). Its almost impossible to work out what is causing the slowdown otherwise.