Search Issue Tracker

Won't Fix



Found in


Issue ID




CPU usage spikes in the Loading.LockPersistentManager when async loading/unloading Scenes

Scene Management


How to reproduce:
1. Open the attached "" project
2. Open the "Game Streamer Scene" Scene (Assets/NatureManufacture Assets/WorldStreamer/Tutorial Work and Game Scenes)
3. Make sure the Profiler window is opened (Window -> Analysis -> Profiler)
4. Enter Play Mode
5. Move the Camera in the Game view with WASD keys while holding the shift key on the keyboard
6. Press the Pause button when huge CPU usage spikes in the Profiler window are visible
7. Observe the Profiler's Overview section of the spikes

Expected result: No CPU usage spikes are in the Loading.LockPersistentManager in the Profiler's Overview section
Actual result: A huge CPU usage spike in the Loading.LockPersistentManager (Around 60 % usage can be seen in the Profiler's Overview section)

Reproducible with: 2019.4.13f1, 2020.1.10f1, 2020.2.0b8, 2021.1.0a1
Could not test with: 2018.4.28f1 (Due to errors with missing functionality)

- Originally the case was reported against terrain as the spike happens inside CullAllTerrains.
- After investigation we found the true reason behind it was that the PersistentManager locks up all PPtr dereferences while scenes are being asynchronously loaded.
- The original case was then resolved as fixed (1276854) but the fix was only for terrain, where it tries to avoid PPtr dereferencing as much as possible.
- But the real fix is still yet to be made because PPtr can still happen anywhere, including in user scripts. Steen said it won't be an easy fix for PersistentManager not to lock up the main thread.
- Keep this bug here so we can track the progress.

  1. Resolution Note:

    The original issue was fixed and the generic case is unlikely to get fixed. They need to be treated case by case by the system owners.

Comments (4)

  1. enikey87

    Feb 18, 2022 03:12

    This bug makes testing game in editor unplayable cause every time I load new scene with LoadSceneAsync() in got stuck in LOCKPERSISTENTMANAGER per 1 minute.

  2. LabOSM

    Apr 07, 2021 16:30

    Same here Unity 2020.2.0f

  3. Oamm

    Mar 27, 2021 08:35

    My comment above is utilizing latest 2019 LTS

  4. Oamm

    Mar 27, 2021 08:33

    I encounter this issue, or an issue related to this where my scene is stuck loading - very difficult to reproduce, as it doesn't happen often.

    As of writing this, my editor is currently stuck waiting for the past 20 minutes, and the following is the callstack obtained.

    Best guess is a mutex is stuck waiting to be locked, based on the .dmp and callstack obtained:
    ntdll.dll!00007fffc7630604() Unknown
    ntdll.dll!00007fffc75f379d() Unknown
    ntdll.dll!00007fffc75f3652() Unknown
    ntdll.dll!00007fffc75f346d() Unknown
    ntdll.dll!00007fffc75bfcb4() Unknown
    ntdll.dll!00007fffc75bfae2() Unknown
    > Unity.exe!PersistentManager::Lock(enum PersistentManager::LockFlags,class profiling::Marker *) Unknown
    Unity.exe!PersistentManager::ReadObject(int,enum AwakeFromLoadMode) Unknown
    Unity.exe!PPtr<class Object>::operator class Object *(void) Unknown
    Unity.exe!EditorUtility_CUSTOM_InstanceIDToObject(int) Unknown
    000002aa42bfcd7e() Unknown
    000002aa42c36123() Unknown
    000002aa42c33343() Unknown
    000002aa42e621c3() Unknown
    000002a7e542acc0() Unknown
    mono-2.0-bdwgc.dll!mono_jit_runtime_invoke(_MonoMethod * method, void * obj, void * * params, _MonoObject * * exc, _MonoError * error) Line 2809 C
    mono-2.0-bdwgc.dll!do_runtime_invoke(_MonoMethod * method, void * obj, void * * params, _MonoObject * * exc, _MonoError * error) Line 2921 C
    mono-2.0-bdwgc.dll!mono_runtime_invoke_checked(_MonoMethod * method, void * obj, void * * params, _MonoError * error) Line 3073 C
    mono-2.0-bdwgc.dll!mono_runtime_try_invoke_array(_MonoMethod * method, void * obj, _MonoArray * params, _MonoObject * * exc, _MonoError * error) Line 5264 C
    mono-2.0-bdwgc.dll!mono_runtime_invoke_array_checked(_MonoMethod * method, void * obj, _MonoArray * params, _MonoError * error) Line 5142 C
    mono-2.0-bdwgc.dll!ves_icall_InternalInvoke(_MonoReflectionMethod * method, _MonoObject * this_arg, _MonoArray * params, _MonoException * * exc) Line 3358 C
    000002a7e4d962d6() Unknown
    000002a7e4d9542b() Unknown
    000002a7e4d950ef() Unknown
    000002aa42da6733() Unknown
    000002aa42da5dfb() Unknown
    000002aa42da5cd5() Unknown
    000002aa42da5adb() Unknown
    000002a93c0ef5a5() Unknown
    000002a93b5ed860() Unknown
    ffffffffffffffff() Unknown
    000000df330eee90() Unknown
    mono-2.0-bdwgc.dll!mono_method_signature(_MonoMethod * m) Line 2611 C
    000002a93b5ed860() Unknown
    000002a5dfa00000() Unknown

    Fortunately isn't a 100% occurrence, but when it does occur it's always frustrating, and a bit of a blocker due to the randomness of how it occurs when it occurs.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.