[RESOLVED] Editor stuck on importing prefabs with addressable dependencies

Hi, there!

Trying to find obvious solution, or known problem or any workaround at all for problem listed below. Tried everything, out of options and looking for any suggestions, other than just reimport library every time (it takes 20 min even with CacheServer and it hurts).

Unity: 2021.3.29f1
Addressables: 1.21.17
Platform: MacOS, Windows
Environment: Git + Jenkins

Way to Reproduce:

  1. Local - Create huge prefab with deep hierarchy and a lot of references to addressable sprites, prefabs, sounds, etc. Dependencies are addressables. Prefab is not.
  2. Local - Commit and Push
  3. Node - Pull and start project re-import by deleting Library and opening Unity.
  4. Local - Make any change in prefab
  5. Local - Commit and Push
  6. Node - Pull and run build /Applications/.../Unity -projectPath ... -nographics -batchmode -buildTarget ... -executeMethod Builder.Build -otherArgs …

Actual Result:
Changes in prefab triggers ConsistencyCheck on importing prefab changes. By this AwakeFromLoadQueue was triggered. By this AssetBundle references start loading, but never finished. Editor stuck: kinda responding, but do nothing.

Known Limitations:

  • Only appear on editor startup from command-line, opening Editor with project totally fine.
  • Using “-logFile -” instead of “-nographics -batchmode” kinda solves issue, but unstable: it didn’t suppress dialogs and finally got stuck on building addressables, “Calculating Scene Dependencies” dialog.
    - Small prefabs are unharmed, only huge ones are hit.
  • Problem are ONLY with prefabs
  • Reproduction rate is almost 100%, but not quite. Trying to find problematic reference by diсhotomy on target prefab leads nowhere, behaviour is not bound to references and can disappear on any next prefab import.
  • Sampling Editor process in this state are stable, always produce same dump.

Part of Dump for Search:

2062 Thread_12198989   DispatchQueue_1: com.apple.main-thread  (serial)
    + 2062 start  (in dyld) + 1942  [0x7ff805c4f3a6]
    + 2062 main  (in Unity) + 9  [0x10b16fec9]
    + 2062 EditorMain(int, char const**)  (in Unity) + 928  [0x10b16fb90]
    + 2062 NoGraphicsMain()  (in Unity) + 46  [0x10b16f4ce]
    + 2062 Application::InitializeProject()  (in Unity) + 18237  [0x10a20086d]
    + 2062 InitialRefreshV2(bool)  (in Unity) + 60  [0x10a6c77dc]
    + 2062 StopAssetImportingV2Internal(AssetDatabase::UpdateAssetOptions, InternalRefreshFlagsV2, ScanFilter const*, char const*)  (in Unity) + 2085  [0x10a6c57e5]
    + 2062 RefreshInternalV2(AssetDatabase::UpdateAssetOptions, ScanFilter const&, InternalRefreshFlagsV2)  (in Unity) + 22258  [0x10a6ea622]
    + 2062 AssetImportManager::Import(core::hash_map<AssetDatabase::ImporterID, ImporterInfo, core::hash<AssetDatabase::ImporterID>> const&, dynamic_array<PostprocessorInfo, 0ul> const&, AssetResolver&, CategorizedAssets&, IImportProgress*, core::hash_set<UnityGUID, core::hash<UnityGUID>> const&, LoadedImportedAssetsSnapshot*, LoadedSourceAssetsSnapshot*, core::hash_set<core::basic_string<char, core::StringStorageDefault<char>>, core::hash<core::basic_string<char, core::StringStorageDefault<char>>>>&, CrashedAssetImportsDatabase&, OnDemandScheduler&)  (in Unity) + 5597  [0x10a6c32ad]
    + 2062 AssetImportManager::ImportInProcess(AssetResolver&, ArtifactKey const&, AssetImportParameters const&, AssetDatabase::ArtifactID&, IImportProgress*, core::hash_set<core::basic_string<char, core::StringStorageDefault<char>>, core::hash<core::basic_string<char, core::StringStorageDefault<char>>>>&, CrashedAssetImportsDatabase&)  (in Unity) + 979  [0x10a6d7b73]
    +  2062 AssetImportWorker::Import(AssetResolver&, ImportAssetInputs const&, WorkerImportResponse&, IImportProgress*, bool*)  (in Unity) + 299  [0x10a68e85b]
    +  2062 ImportAssetWithAutoReleasePool(core::hash_map<AssetDatabase::ImporterID, ImporterInfo, core::hash<AssetDatabase::ImporterID>> const&, dynamic_array<PostprocessorInfo, 0ul> const&, AssetResolveTracker const&, ImportAssetInputs const&, ImportAssetOutputs&, IImportProgress*)  (in Unity) + 70  [0x10b2c6236]
    +  2062 ImportAsset(core::hash_map<AssetDatabase::ImporterID, ImporterInfo, core::hash<AssetDatabase::ImporterID>> const&, dynamic_array<PostprocessorInfo, 0ul> const&, AssetResolveTracker const&, ImportAssetInputs const&, ImportAssetOutputs&, IImportProgress*)  (in Unity) + 216  [0x10a661598]
    +  2062 ImportToObjects(core::basic_string<char, core::StringStorageDefault<char>> const&, core::hash_map<AssetDatabase::ImporterID, ImporterInfo, core::hash<AssetDatabase::ImporterID>> const&, dynamic_array<PostprocessorInfo, 0ul> const&, AssetResolveTracker const&, ImportAssetInputs const&, ImportAssetOutputs&, IImportProgress*)  (in Unity) + 3228  [0x10a66264c]
    + 2062 PrefabImporter::GenerateAssetData(AssetImportContext&)  (in Unity) + 1432  [0x10a0c9248]
    + 2062 MergeAllPrefabInstancesDuringLoad(AwakeFromLoadQueue*, TransferInstructionFlags, ErrorsAndWarningsCapture*)  (in Unity) + 3745  [0x109e6ef51]
    + 2062 IsPrefabInstanceWithValidParent(Object*)  (in Unity) + 74  [0x109e6aa7a]
    + 2062 PPtr<EditorExtension>::operator EditorExtension*() const  (in Unity) + 305  [0x108a247f1]
    + 2062 PersistentManager::ReadObject(int, AwakeFromLoadMode)  (in Unity) + 499  [0x109308993]
    + 2062 PersistentManager::LoadAndIntegrateAllPreallocatedObjects(PersistentManager::LockFlags)  (in Unity) + 188  [0x109309d7c]
    + 2062 PersistentManager::IntegrateAllThreadedObjects()  (in Unity) + 95  [0x109308f3f]
    + 2062 AwakeFromLoadQueue::PersistentManagerAwakeFromLoad(int, AwakeFromLoadMode, bool)  (in Unity) + 294  [0x109335656]
    + 2062 AwakeFromLoadQueue::InvokePersistentManagerAwake(AwakeFromLoadQueue::Item*, unsigned int, AwakeFromLoadMode, bool)  (in Unity) + 174  [0x10933582e]
    + 2062 MonoBehaviour::CheckConsistency()  (in Unity) + 211  [0x10920da93]
    + 2062 SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr)  (in Unity) + 116  [0x1092f6774]
    + 2062 ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*)  (in Unity) + 54  [0x1092485c6]
    + 2062 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)  (in Unity) + 166  [0x1092486f6]
    + 2062 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)  (in Unity) + 71  [0x10926c267]
    + 2062 mono_runtime_invoke  (in libmonobdwgc-2.0.dylib) + 94  [0x1623a11e0]
    + 2062 do_runtime_invoke  (in libmonobdwgc-2.0.dylib) + 80  [0x1623a12a3]
    + 2062 mono_jit_runtime_invoke  (in libmonobdwgc-2.0.dylib) + 1587  [0x1621eb8dc]
    + 2062 ???  (in <unknown binary>)  [0x174379189]
    + 2062 ???  (in <unknown binary>)  [0x17438bfc9]
    + 2062 AssetBundleCreateRequest_Get_Custom_PropAssetBundle(ScriptingBackendNativeObjectPtrOpaque*)  (in Unity) + 103  [0x108746157]
    + 1351 AssetBundleLoadFromAsyncOperation::GetAssetBundleBlocking()  (in Unity) + 59  [0x10964532b]
    + ...

9461315–1329029–sample.txt (285 KB)

It looks like strange that it tried to load an asset bundle synchronously while the assets are being imported.

Can you try to use Visual Studio to attach debugger to Editor to see which managed code is calling AssetBundlCreateRequest.assetBundle?

Ok, this advice actually lead me to solution! Thank you!

So, if anyone will bump into this, here is a missing stack trace part:

[Native Transition]
Thread.Sleep()
AssetBundleResource.WaitForCompletionHandler()
ProviderOperation<IAssetBundleResource>.InvokeWaitForCompletion()
AsyncOperationBase<IAssetBundleResource>.WaitForCompletion()
AsyncOperationHandle.WaitForCompletion()
GroupOperation.InvokeWaitForCompletion()
AsyncOperationBase<IList<AsyncOperationHandle>>.WaitForCompletion()
AsyncOperationHandle<IList<AsyncOperationHandle>>.WaitForCompletion()
ProviderOperation<Object>.InvokeWaitForCompletion()
AsyncOperationBase<Object>.WaitForCompletion() [2]
AsyncOperationHandle<Object>.WaitForCompletion() [2]
ChainOperationTypelessDepedency<Object>.InvokeWaitForCompletion()
AsyncOperationBase<Object>.WaitForCompletion() [1]
AsyncOperationHandle<Object>.WaitForCompletion() [1]
AddressableLoadAssetHandler.WaitForCompletion()
AddressableLoadAssetHandler.Immediate<ThemeConfigData>()
ThemeConfigData.Load()
ThemeGlobalConfig.get_Config()
TargetBehaviour.ApplyGlobalConfig()
TargetBehaviour.OnValidate()

In one of the plugins, addressable code was called from OnValidate() method. After blocking execution with InternalEditorUtility.inBatchMode check, problem was solved.