Search Unity

UIAlert or Keyboard causing drop to 5FPS

Discussion in 'iOS and tvOS' started by akasurreal, Feb 12, 2011.

  1. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    I have not been able to narrow down if this is Unity 3.2 related (vs 3.1) yet, but we are having an issue where if I popup an UIAlert dialog or the keyboard, the framerate goes down to 5FPS or less and stays there even after I dismiss the popup. Any ideas? This is delaying a very much needed update! Thanks for any help!
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    Run your game under the profiler. What's taking up the time?
     
  3. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    Before the UIAlert:

    Code (csharp):
    1.  
    2. iPhone Unity internal profiler stats:
    3. cpu-player>    min:  6.7   max: 27.9   avg: 12.3
    4. cpu-ogles-drv> min:  0.6   max:  2.4   avg:  0.8
    5. cpu-waits-gpu> min:  0.0   max:  0.0   avg:  0.0
    6.  msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
    7. cpu-present>   min:  1.3   max: 20.9   avg:  4.3
    8. frametime>     min: 14.7   max: 40.1   avg: 24.8
    9. draw-call #>   min:   5    max:   7    avg:   5     | batched:     4
    10. tris #>        min:   160  max:   164  avg:   160   | batched:   108
    11. verts #>       min:   320  max:   328  avg:   320   | batched:   216
    12. player-detail> physx:  1.0 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.1 render:  7.9 fixed-update-count: 0 .. 3
    13. mono-scripts>  update:  1.8   fixedUpdate:  0.1 coroutines:  0.6
    14. mono-memory>   used heap: 356352 allocated heap: 479232  max number of collections: 0 collection total duration:  0.0
    15.  
    After dismissing the UIAlert:

    Code (csharp):
    1.  
    2. iPhone Unity internal profiler stats:
    3. cpu-player>    min:  9.2   max: 70.6   avg: 27.0
    4. cpu-ogles-drv> min:  0.5   max:  1.5   avg:  0.7
    5. cpu-waits-gpu> min:  0.0   max:  0.0   avg:  0.0
    6.  msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
    7. cpu-present>   min:  1.2   max:  1.9   avg:  1.5
    8. frametime>     min: 35.8   max: 571.6   avg: 271.6
    9. draw-call #>   min:   5    max:   5    avg:   5     | batched:     4
    10. tris #>        min:   180  max:   180  avg:   180   | batched:   108
    11. verts #>       min:   360  max:   360  avg:   360   | batched:   216
    12. player-detail> physx: 10.1 animation:  0.1 culling  0.0 skinning:  0.0 batching:  0.1 render:  9.9 fixed-update-count: 2 .. 29
    13. mono-scripts>  update:  1.6   fixedUpdate:  1.3 coroutines:  3.8
    14. mono-memory>   used heap: 372736 allocated heap: 479232  max number of collections: 0 collection total duration:  0.0
    15.  
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    That's strange. Can you try unity builtin-profiler (that thingy in editor). If you build development build and auto-connect it should work right away
     
  5. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    That new profiler is pretty slick, hadn't played with it yet. The interesting thing though is that it thinks the frames are still being rendered pretty much just as quickly after UIAlert even though its far from that. Not sure what else I can ascertain from that. I am going to try completely wiping this device and reinstalling it, because I tried another iPhone3G with same OS and it is not having this problem. They should be identical.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    sure you also destroyed the view controller that called them up?
    not just the views themself?
     
  7. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    Ok so I just did a full factory restore through iTunes on this device and it is still having the same problem.

    @dreamora, It's pretty simple what I am doing, and it's only causing a problem on one device so I would imagine it would be breaking all of them if I was missing something like that. Also I don't think you understand how poorly it runs. As the UIAlert comes on and you can see each frame of its bounce animation happening over a few seconds.

    Here's the relevant code:

    Code (csharp):
    1.  
    2. - (void)showPrompt
    3. {
    4.     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title
    5.     message:msg delegate:self cancelButtonTitle:CANCEL_BUTTON otherButtonTitles:RATE_BUTTON, RATE_LATER, nil];
    6.     [alertView show];
    7. }
    8.  
    9. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    10. {  
    11. //do stuff
    12.    
    13.     [alertView release];
    14.     [self release];
    15. }
    16.  
    As soon as the Alert comes up, FPS drops to about 4. After dismissing the UIAlert, the FPS never recovers though and stays at 4. Again, for some reason I am not seeing this behavior at all on my other iPhone 3G 4.2.1 that should be identical in every way. I am concerned that this is affecting some percentage of people and would like to be sure.
     
  8. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    Some more to update this very strange problem. I downgraded this phone to OS3.1.3 and there is no problem, then I tried OS4.1 and no problem again. Went back to 4.2.1 from a fresh install (not backup), and the problem re-appears. *very confused*
     
  9. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
  10. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    442
    Thanks but there is obviously something wrong that goes beyond a performance tweak. This doesn't seem to happen on any other device so unless I hear otherwise from our customers, I will assume its a fluke.
     
  11. esdin

    esdin

    Joined:
    Jul 19, 2011
    Posts:
    12
    Sorry to raise this thread from the dead, but I'm currently experiencing similar issues.
    Before we launch a notification, the performance is smooth. After launching and dismissing, the game suffers noticeably.

    If we suspend the application and resume it, the issue goes away until another notification is used. We have confirmed this as an issue on multiple iOS devices, including current generations and older models.