Search Unity

iOS large CPU spike/hang intermittently around AutoReadLockT

Discussion in 'iOS and tvOS' started by Nabren, Jul 17, 2018.

  1. Nabren

    Nabren

    Joined:
    Mar 7, 2014
    Posts:
    61
    On a couple devices (iPad Air 1 & 2) we are seeing problems with the CPU spiking and locking the main thread. This was tested under Unity 2018.1.8f1.

    Using Xcode instruments we have noticed that when the CPU spikes on the main thread there is also another thread showing the exact same spike and it appears to be a graphics worker thread with the entry function being GfxDeviceWorker::RunGfxDeviceWorker(void*).

    Both threads effectively stall on "AutoReadLockT" for varying amounts of time between 20-60 seconds but the issue does eventually resolve itself. The stack trace varies slightly when we can reproduce the issue, but the stack trace is always the same at the final few lines:

    AutoReadLockT
    GetAllocationRoot
    MemoryProfiler::UnregisterAllocation
    MemoryProfiler::UnregisterAllocation
    MemoryManager::RegisterDeallocation
    MemoryManager::Deallocate
    deallocate


    One of the places this happens on the main thread is from AnimatorController::MainThreadCleanup which calls AnimatorController::ClearAsset which eventually hits the stall on AutoReadLockT.

    We haven't been able to narrow down exactly what is causing this. Unfortunately it seems to be just playing the game for ~30 minutes and eventually it will happen. Has anyone run into something similar or have any troubleshooting suggestions?
     
    Last edited: Jul 17, 2018
    TamuraKazunori likes this.
  2. TamuraKazunori

    TamuraKazunori

    Joined:
    Jul 27, 2017
    Posts:
    2
    I have also encountered the very same problem.
    this problem seems to occur only in Unity 2018(not in Unity 2017).
    It tends to be reproduced if I repeat large amount of generation and destruction of assets.
    In my situation, this issue will not occur if I turn off the "Development Build" flag.
    This may be a bug which happened from Unity 2018...
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    I have been investigating this issue. It should only happen in development build.
    The solution is being worked on.
     
    iteterin, Nabren and TamuraKazunori like this.
  4. iteterin

    iteterin

    Joined:
    May 28, 2018
    Posts:
    1
    Hi, the very same symptoms we see in our project. Is there a ticket we can follow to get the status of the issue? We're now on 2018.1.6f1.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    I don't see a ticket for this, but check the release notes for "performance".
    Note that 2018.1 is EOL, so if you are on latest and have the issue, you're not getting the fix, you'll have to either upgrade or use non-development build.
     
  6. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    Hi! Does this mean Unity 2018.2 will get a fix for this eventually?

    We have been having this issue when calling Resources.UnloadUnusedAssets. The game freezes to AutoReadLockT, with both main thread and GfxDeviceWorker having high CPU usage. It will stay like that for several minutes. Tested on Unity 2018.2.6 and 2018.2.9, different Apple devices and iOS versions.

    Haven't tried non-development build yet, but I will do that next.

    EDIT: Here's a trace from instruments:
     
    Last edited: Oct 12, 2018
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    I don't know how far the fixes are going to get backported. But the issue is in code that is only in development build, so release build should be fine. If what you hit is the same issue, of course.
     
    Havokki likes this.
  8. YuriGrachev

    YuriGrachev

    Joined:
    Jul 12, 2016
    Posts:
    6
    Last edited: May 20, 2019