Search Unity

Question PrefabUtility.LoadPrefabContents getting stuck

Discussion in 'Editor & General Support' started by anguha, May 28, 2023.

  1. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    I have a custom build script. After Upgrading to Unity 2021.3.14f1 from Unity2020, For certain prefabs, I notice that
    Code (CSharp):
    1. PrefabUtility.LoadPrefabContents
    is getting stuck. I don't see any related error or warning logs as well. From my custom logs, I can see that it just seems to get stuck.
     
  2. luskos

    luskos

    Joined:
    Mar 4, 2013
    Posts:
    48
    So I can Imagine it has hard time getting an object out of the prefab as Unity Documentation states that's what this does. Share the script you wish for further help. Try Refreshing the project inside unity.
     
  3. anguha

    anguha

    Joined:
    May 4, 2023
    Posts:
    23
    So I noticed after upgrading to Unity 2021.3.14f1 that its getting stuck at loading prefabs randomly (not a set of specific prefabs only). I tried alternate approach like using EditPrefabContentsScope instead of manually loading saving and unloading. Still seems to get stuck.

    I managed to get a sample crash log that I have shared below. As a result of this type of error, my Unity build is failing with segmentation fault. Please help, have been stuck on this for more than a week now.

    Code (CSharp):
    1. Obtained 88 stack frames.
    2. #0  0x000002c5b2969c in mono_object_get_class
    3. #1  0x000001039e6b14 in Scripting::FindObjectsOfType(ScriptingSystemTypeObjectPtr, Scripting::FindMode, bool)
    4. #2  0x00000102def90c in ResourcesAPIInternal_CUSTOM_FindObjectsOfTypeAll(ScriptingBackendNativeObjectPtrOpaque*)
    5. #3  0x000002ee8cb8bc in  (wrapper managed-to-native) UnityEngine.ResourcesAPIInternal:FindObjectsOfTypeAll (System.Type) [{0x2ce370dc0} + 0xa4]  (0x2ee8cb818 0x2ee8cb970) [0x2c0182a80 - Unity Child Domain]
    6. #4  0x000002ee8cb7a0 in  UnityEngine.ResourcesAPI:FindObjectsOfTypeAll (System.Type) [{0x2ce370b80} + 0x58] [/Users/bokken/build/output/unity/unity/Runtime/Export/Resources/Resources.bindings.cs :: 69u] (0x2ee8cb748 0x2ee8cb7c4) [0x2c0182a80 - Unity Child Domain]
    7. #5  0x000002ee8cb384 in  UnityEngine.Resources:FindObjectsOfTypeAll (System.Type) [{0x2ce3705a0} + 0x84] [/Users/bokken/build/output/unity/unity/Runtime/Export/Resources/Resources.bindings.cs :: 100u] (0x2ee8cb300 0x2ee8cb3bc) [0x2c0182a80 - Unity Child Domain]
    8. #6  0x000002f765ebec in  UnityEditor.U2D.Sprites.SpriteEditorTexturePostprocessor:OnPostprocessAllAssets (string[],string[],string[],string[]) [{0x2ec577208} + 0xa4] [/Users/anguha/Documents/workspace/Tropic-2/TropicThunder/Library/PackageCache/com.unity.2d.sprite@1.0.0/Editor/SpriteEditor/SpriteEditorWindow.cs :: 1376u] (0x2f765eb48 0x2f765eec0) [0x2c0182a80 - Unity Child Domain]
    9. #7  0x000002f765f12c in  (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_object_object_object (object,intptr,intptr,intptr) [{0x2ec577b40} + 0x1cc]  (0x2f765ef60 0x2f765f154) [0x2c0182a80 - Unity Child Domain]
    10. #8  0x000002c599d868 in mono_jit_runtime_invoke
    11. #9  0x000002c5b23640 in do_runtime_invoke
    12. #10 0x000002c5b27050 in mono_runtime_try_invoke_array
    13. #11 0x000002c5ad280c in ves_icall_InternalInvoke
    14. #12 0x000002c5ae3200 in ves_icall_InternalInvoke_raw
    15. #13 0x000002c89a9b28 in  (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo:InternalInvoke (System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) [{0x1106f1cf8} + 0xf0]  (0x2c89a9a38 0x2c89a9bfc) [0x2c0182a80 - Unity Child Domain]
    16. #14 0x000002c89a8114 in  System.Reflection.RuntimeMethodInfo:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [{0x2bea73d40} + 0x36c]  (0x2c89a7da8 0x2c89a8294) [0x2c0182a80 - Unity Child Domain]
    17. #15 0x000002c89a7d6c in  System.Reflection.MethodBase:Invoke (object,object[]) [{0x1213d2fc8} + 0x7c]  (0x2c89a7cf0 0x2c89a7da8) [0x2c0182a80 - Unity Child Domain]
    18. #16 0x000002eebe1c80 in  UnityEditor.AssetPostprocessingInternal:InvokeMethod (System.Reflection.MethodInfo,object[]) [{0x121412080} + 0x1e0] [/Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs :: 1145u] (0x2eebe1aa0 0x2eebe1d2c) [0x2c0182a80 - Unity Child Domain]
    19. #17 0x000002eebd5d94 in  UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[],bool) [{0x121411690} + 0x80c] [/Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs :: 385u] (0x2eebd5588 0x2eebd5ff4) [0x2c0182a80 - Unity Child Domain]
    20. #18 0x000002eebd65c0 in  (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_object_object_object_object_byte (object,intptr,intptr,intptr) [{0x2e9f1f6e0} + 0x128]  (0x2eebd6498 0x2eebd66e4) [0x2c0182a80 - Unity Child Domain]
    21. #19 0x000002c599d868 in mono_jit_runtime_invoke
    22. #20 0x000002c5b23640 in do_runtime_invoke
    23. #21 0x000002c5b23560 in mono_runtime_invoke
    24. #22 0x00000103a0a284 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
    25. #23 0x000001039e80f8 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
    26. #24 0x0000010432da1c in MonoPostprocessAllAssets(core::hash_set<UnityGUID, core::hash<UnityGUID>, std::__1::equal_to<UnityGUID> > const&, core::hash_set<UnityGUID, core::hash<UnityGUID>, std::__1::equal_to<UnityGUID> > const&, core::hash_set<UnityGUID, core::hash<UnityGUID>, std::__1::equal_to<UnityGUID> > const&, std::__1::map<UnityGUID, core::basic_string<char, core::StringStorageDefault<char> >, std::__1::less<UnityGUID>, std::__1::allocator<std::__1::pair<UnityGUID const, core::basic_string<char, core::StringStorageDefault<char> > > > > const&, bool, AssetDatabase::UpdateAssetOptions)
    27. #25 0x00000104cbdc80 in StopAssetImportingV2Internal(AssetDatabase::UpdateAssetOptions, InternalRefreshFlagsV2, ScanFilter const*, char const*)
    28. #26 0x00000104cb7d64 in PartialRefreshV2(core::basic_string<char, core::StringStorageDefault<char> > const&, AssetDatabase::UpdateAssetOptions)
    29. #27 0x00000104d67a58 in AssetDatabase::PartialRefresh(core::basic_string_ref<char>, AssetDatabase::UpdateAssetOptions)
    30. #28 0x00000104516130 in SavePrefab_Internal(PPtr<GameObject> const&, core::basic_string<char, core::StringStorageDefault<char> > const&, bool, bool&)
    31. #29 0x00000104516d74 in SaveAsPrefabAsset(PPtr<GameObject> const&, core::basic_string<char, core::StringStorageDefault<char> > const&, bool&)
    32. #30 0x0000010433c274 in PrefabUtilityBindings::SaveAsPrefabAsset_Internal(GameObject&, core::basic_string<char, core::StringStorageDefault<char> > const&, unsigned char&, ScriptingExceptionPtr*)
    33. #31 0x00000103197e3c in PrefabUtility_CUSTOM_SaveAsPrefabAsset_Internal(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeStringPtrOpaque*, unsigned char*)
    34. #32 0x0000033b38d1e4 in  (wrapper managed-to-native) UnityEditor.PrefabUtility:SaveAsPrefabAsset_Internal (UnityEngine.GameObject,string,bool&) [{0x2eac360b0} + 0xc4]  (0x33b38d120 0x33b38d290) [0x2c0182a80 - Unity Child Domain]
    35. #33 0x0000033b38abcc in  UnityEditor.PrefabUtility:SaveAsPrefabAsset (UnityEngine.GameObject,string,bool&) [{0x121466168} + 0x94] [/Users/bokken/build/output/unity/unity/Editor/Mono/Prefabs/PrefabUtility.cs :: 1797u] (0x33b38ab38 0x33b38ac08) [0x2c0182a80 - Unity Child Domain]
    36. #34 0x0000033b38aaa4 in  UnityEditor.PrefabUtility:SaveAsPrefabAsset (UnityEngine.GameObject,string) [{0x121466190} + 0x74] [/Users/bokken/build/output/unity/unity/Editor/Mono/Prefabs/PrefabUtility.cs :: 1803u] (0x33b38aa30 0x33b38aae4) [0x2c0182a80 - Unity Child Domain]
    37. #35 0x0000033b38a94c in  UnityEditor.PrefabUtility/EditPrefabContentsScope:Dispose () [{0x2eac35d10} + 0x6c] [/Users/bokken/build/output/unity/unity/Editor/Mono/Prefabs/PrefabUtility.cs :: 2840u] (0x33b38a8e0 0x33b38a990) [0x2c0182a80 - Unity Child Domain]