Search Unity

EditorApplication.update with Resources.FindObjectsOfTypeAll crashes when going in playmode

Discussion in 'Editor & General Support' started by IroxGames, Apr 7, 2022.

  1. IroxGames

    IroxGames

    Joined:
    Feb 8, 2020
    Posts:
    16
    Since 2021 we experience crashes produced by our tools. They worked fine in earlier Unity Versions
    We are currently working on 2021.2.4f1

    The "EditorWindow.HasOpenInstances" produces the crash if the user enters/exits the playmode.
    The bug occurs very inconsistently and can't be easily reproduced.
    We had multiple scripts hooking up in EditorApplication.update and calling the underlying "Resources.FindObjectsOfTypeAll" all of them produced atleast one crash.

    Our crash stacktrace looks like this:
    Code (CSharp):
    1. ========== OUTPUTTING STACK TRACE ==================
    2.  
    3. 0x00007FF815214F69 (KERNELBASE) RaiseException
    4. 0x00007FFFC40F064C (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\utils\mono-log-common.c:143] mono_log_write_logfile
    5. 0x00007FFFC40DC4A2 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\eglib\goutput.c:172] monoeg_g_logv_nofree
    6. 0x00007FFFC40DC57C (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\eglib\goutput.c:215] monoeg_assertion_message
    7. 0x00007FFFC40DC5E6 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\eglib\goutput.c:239] mono_assertion_message_unreachable
    8. 0x00007FFFC414E826 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\class-accessors.c:86] mono_class_get_flags
    9. 0x00007FFFC4144195 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\class-init.c:253] mono_class_setup_fields
    10. 0x00007FFFC4148852 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\class-init.c:1768] init_sizes_with_info
    11. 0x00007FFFC414B021 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\class-init.c:2835] mono_class_init_internal
    12. 0x00007FFFC413D3FD (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\class.c:3530] mono_class_is_subclass_of_internal
    13. 0x00007FFFC4238123 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\external-only.c:319] mono_class_is_subclass_of
    14. 0x00007FF6648CD97D (Unity) scripting_class_is_subclass_of
    15. 0x00007FF6648C7B9E (Unity) Scripting::FindObjectsOfType
    16. 0x00007FF6647E0555 (Unity) Resources_Bindings::FindObjectsOfTypeAll
    17. 0x00007FF663BE3A1E (Unity) ResourcesAPIInternal_CUSTOM_FindObjectsOfTypeAll
    18. 0x0000026EED1CC46A (Mono JIT Code) (wrapper managed-to-native) UnityEngine.ResourcesAPIInternal:FindObjectsOfTypeAll (System.Type)
    19. 0x0000026EED1CC3B3 (Mono JIT Code) UnityEngine.ResourcesAPI:FindObjectsOfTypeAll (System.Type)
    20. 0x0000026EED1CC1EB (Mono JIT Code) UnityEngine.Resources:FindObjectsOfTypeAll (System.Type)
    21. 0x0000026F67408D6B (Mono JIT Code) UnityEditor.EditorWindow:HasOpenInstances<T_REF> ()
    22. 0x00000270800916FB (Mono JIT Code) [...\Assets\Scripts\BuildTest\Editor\BuildMachineTest.cs:242] BuildTest.BuildMachineTest:OnUpdate ()
    23. 0x000002708004F0F0 (Mono JIT Code) UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
    24. 0x0000026F6C641CB5 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
    25. 0x00007FFFC42FE034 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke
    26. 0x00007FFFC423E724 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3064] do_runtime_invoke
    27. 0x00007FFFC423E8BC (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3111] mono_runtime_invoke
    28. 0x00007FF6648CE5F4 (Unity) scripting_method_invoke
    29. 0x00007FF6648C9274 (Unity) ScriptingInvocation::Invoke
    30. 0x00007FF6648C2C25 (Unity) ScriptingInvocation::Invoke<void>
    31. 0x00007FF6649E39BB (Unity) Scripting::UnityEditor::EditorApplicationProxy::Internal_CallUpdateFunctions
    32. 0x00007FF665316CC2 (Unity) SceneTracker::Update
    33. 0x00007FF6654C43E6 (Unity) Application::TickTimer
    34. 0x00007FF6658FFD0A (Unity) MainMessageLoop
    35. 0x00007FF66590452B (Unity) WinMain
    36. 0x00007FF666C13702 (Unity) __scrt_common_main_seh
    37. 0x00007FF817397034 (KERNEL32) BaseThreadInitThunk
    38. 0x00007FF817A22651 (ntdll) RtlUserThreadStart
    39.  
    40. ========== END OF STACKTRACE ===========
    The code referenced:
    Code (CSharp):
    1.  
    2. static BuildMachineTest()
    3. {
    4.      EditorApplication.update -= OnUpdate;
    5.      EditorApplication.update += OnUpdate;
    6. }
    7.  
    8. private static void OnUpdate()
    9. {
    10.      if (EditorWindow.HasOpenInstances<BuildPlayerWindow>()){...}
    11. }
    12.  
    Is this a known issue? Am i using the editor callbacks wrong?

    Thanks for your help!
     
  2. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    12
    Same here !
    We have multiple tools on our build machines, all of them worked in 2020.3.10 and now that we are in 2021.3.13 crashes occur systematically. So far we observed this :
    - Crashes happen between 30 min and +4 hours
    - It happens on different tools
    - For a given tool the stack traces vary (Native Crash Stack Trace)
    - It happens on different computers
    - Processed assets vary
    - Enabling 'AssetPipeline Parallel Import' doesn't change anything.
    - Also happen in 2021.3.14 (with more issues related to the AssetDatabase)
     
    Last edited: Nov 24, 2022