Search Unity

Performance/framerate improves when leaving and re-entering Android app

Discussion in 'Editor & General Support' started by Mitnainartinarian, Aug 5, 2017.

  1. Mitnainartinarian

    Mitnainartinarian

    Joined:
    Jun 3, 2017
    Posts:
    16
    I'm trying to optimize a 2D app using the Unity Profiler. The app usually runs at near 60 fps on a Galaxy S7 and S6. But sometimes the framerate drops to around 40-50 fps. This often happens after a few minutes of use. When I leave the app (by pressing the device's home button) and then re-enter it, the framerate goes back up to ~60fps for several minutes, and then sometimes eventually goes back down to ~40 fps. There is no change in scene or other things that are running when I leave and re-enter, it just resumes where it left off.

    I can't figure out what is causing it and was hoping someone might have had a similar issue and found a solution or explanation. The app generates several meshes each frame, although the number of meshes is fairly small, but there is a fair amount of heap allocations, which I've tried to minimize. I figure if it was the GC causing the problems it would be more obvious in the profiler. I've attached a screen shot from the profiler attached to the app running on the device itself. The large spikes come from EarlyUpdate.PollPlayerConnection -> ProfilerConnection Poll (around 35 ms each). I'm guessing that has something to do with the profiler and that I can ignore that (correct me if I'm wrong). You can see the transition from leaving then re-entering the app, slightly to the right of the cursor, immediately at where the first large spike after the cursor is. It seems that all the durations in the profiler bands get scaled down, and if I look at the overview panel, the scaling is also reflected in the time columns, so it seems more of a global effect rather than due to one particular component.

    Is it possible that it's due to overheating? If I run the app long enough the device does heat up a bit, but the performance problem also occurs when I can't notice any heating (by touch), including if it's been a while since the device was last used, and I also get 60 fps when the heating is noticeable. And if that was the problem why would the framerate go back up to 60 when I leave and re-enter the app?


    upload_2017-8-5_12-13-19.png

    The other panels (rendering, memory, etc) do not show anything unusual except for the UI panel (where there's a slight drop in the Layout band, from around 1 ms to slightly less than 1 ms), and the Physics 2D panel, which shows more oscillations during the low frame rate period, but I'm not sure if that's a cause or effect of the low framerate. I placed the cursor at the point where I leave then re-enter the app:

    upload_2017-8-5_12-34-39.png
     

    Attached Files:

    thevolcano and Miscellaneous like this.
  2. Miscellaneous

    Miscellaneous

    Joined:
    Sep 24, 2013
    Posts:
    53
    I am also experiences spikes with EarlyUpdate.PollPlayerConnection -> ProfilerConnection Poll on a linux headless build.

    Did anyone have more to report on this issue?
     

    Attached Files:

  3. cassius

    cassius

    Joined:
    Aug 5, 2012
    Posts:
    125
    Same. Nearly 30ms on a Windows build. Not sure what introduced it yet.