Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Mobile (Android) performance drop

Discussion in 'General Graphics' started by Reson_one, Jan 12, 2021.

  1. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    Hello, we are using Unity 2019.4.17 (standart build-in RP)

    BatchRenderer.Flush in same scene with same polygon/vertex/batches/drawcalls count takes x2 longer time to execute with no reason on some devices after 5-7 minutes of playing and continues until the game is completely restarted

    Spikes are not related to any scene changes

    Profiler .data file for the full view: https://drive.google.com/file/d/1QMeQwPNT1gs5C_M8UI4H0Wsl0vnjjFrj/view?usp=sharing

    Normal state:
    upload_2021-1-12_16-37-50.png

    Not normal state:
    upload_2021-1-12_16-37-36.png
     
    Last edited: Jan 12, 2021
  2. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Judging by the time when the problem appears and the profiler gaps between draw calls, I suspect the Android device overheats, and due to thermal throttling the performance drops. Restarting the game just allows a brief moment for the device to slightly cool down, and subsequent run will still reach the thermal throttling temperature faster.
     
    JamesArndt likes this.
  3. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    We measured the temperature, and it is stable (34 degrees) at the beginning of the session (when the FPS is high) and at the end of the session (when the performance drops)
     
  4. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    We moved to Unity 2019 from the old version 2018.4, which did not have this performance drop
     
  5. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    That looks like device surface temperature that you have measured. GPU/CPU core temperature is what matters more in this case, it should be measured with device specific profiling tools.

    Another possible explanation for the 2x performance drop would be if for some reason the Android OS decides to move both Unity Main and Unity Render thread to the same CPU core, essentially preventing multithreaded rendering.
     
  6. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    Can we avoid moving threads to one core somehow?
     
  7. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    We see this drops not only on one device - its reported by lot of users (more than 1k) and non of them had this problems on 2018.4
     
  8. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Unlikely, It's not suppose to happen in the first place, but it depends on the Android OS CPU scheduler how it manages the cpu load. Overall it's not guaranteed that this is the issue here. To make any meaningful insights the reproduction project is needed and a list of devices that show this behavior. Device specific profiling tools would shows more information about what is going on.

    Maybe there is some kind of corellation among the users which experience this issue, for example a specific android device or android version, maybe the device cpu core count...
     
  9. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    After some debug we found that ap crush after lagging with Imkd

    2021.01.16 20:35:06.236 3640 3640 Info lmkd Reclaim Mem 'com.Nobodyshot.kuboom' (31589), uid 10321, oom_adj 0, state 2 to free 765148kB

    Is it posible that lagging has corelation with low memory? Unity Profiler dont show any memory leaks - its stable around 500 Mb...
     
  10. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    It could be, maybe you're using some kind of native plugin which leaks memory, you should try profiling with Android studio, see what it show about memory usage.
     
  11. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Is it possible that there is disparity between the Android SDK version requirement for the different versions of the Unity Editor? I mention this because I believe in later versions of the Android SDK/API Levels there has been increased throttling of the hardware at the OS level. What Android folks called "sustained performance" throttling. As @rjonaitis has proposed, profiling using both Unity's tools and the Android SDK profiling tools is a good step in deducing where performance issues are stemming from.
     
  12. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    @rjonaitis
    We use same Android SDK in 2018.4 and 2019 - so maybe problem in unity editor but not Android?
    Only difference is Unity version and NDK version

    Profiling android studio showed no strange activity
     
    JamesArndt likes this.
  13. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Okay sounds like you are eliminating what it might not be. I confused the SDK with the NDK version. Unity requires a specific version of the NDK tools for different versions of the Unity editor when building using IL2CPP. I am unsure, but I don't believe this would have any impact on performance within a running build of your game.

    https://docs.unity3d.com/Manual/android-sdksetup.html
     
  14. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Can you capture the game's development build when the performance has dropped with android's systrace and share it? https://developer.android.com/topic/performance/tracing/on-device
     
  15. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
  16. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    @rjonaitis Sorry, it looks like this trace was not made with a development build. We will do it again now...
     
  17. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    Initial look shows that, the Unity Main and Graphics threads are moved onto the same cpu core, because the other big cpu core is busy with unknown thread doing a lot of work. The trace does not have any info what it could be, but it's in your application. Are you using graphics jobs or any other jobs system?
     
  18. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    Do You mean thread 423?
    upload_2021-1-25_19-43-2.png

    We dont use any job system or Thread in our game. We are use only 3 3rdparty native plugins: Photon, Google Play Games and Vivox

    Photon is same as were in 2018.4 build - worked ok
     
  19. rjonaitis

    rjonaitis

    Unity Technologies

    Joined:
    Jan 5, 2017
    Posts:
    115
    It's actually two threads 423 and 534 constantly running, hogging cpu time. I can't tell anything else from the trace.
    Try disabling plugins or enabling more debug information, see if anything changes.
     

    Attached Files:

  20. RotationGames

    RotationGames

    Joined:
    Apr 27, 2017
    Posts:
    2
    Hello, did you find a solution to this problem?
     
  21. Reson_one

    Reson_one

    Joined:
    Oct 9, 2016
    Posts:
    21
    The bug was in the Vivox SDK