Search Unity

4.3 Editor Crash - Changing Script

Discussion in 'Editor & General Support' started by LightStriker, Feb 18, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Assuming the following two scripts;

    Code (csharp):
    1.  
    2. public class WithoutGUI : MonoBehaviour { }
    3.  
    and

    Code (csharp):
    1.  
    2. public class WithGUI : MonoBehaviour
    3. {
    4.     private void OnDrawGizmos()
    5.     {
    6.         Gizmos.DrawSphere(Vector3.zero, 10f);
    7.     }
    8. }
    9.  
    Switching the script applied to a GameObject from one to the other using the "Script" field makes the Editor crash 100% of the time with the following callstack;

    Code (csharp):
    1.  
    2.  
    3. ========== OUTPUTING STACK TRACE ==================
    4.  
    5. (0x00826949) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\scriptingarguments.cpp (169 + 0x6): ScriptingArguments::AdjustArgumentsToMatchMethod + 0x9
    6. (0x00826BDC) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\scriptinginvocation.cpp (136 + 0x0): ScriptingInvocation::AdjustArgumentsToMatchMethod + 0xc
    7. (0x00E18CC3) c:\buildagent\work\d3d49558e4d408f4\editor\src\gizmos\gizmodrawers.cpp (659 + 0xe): DrawMonoGizmo + 0xa3
    8. (0x00E1AAF6) c:\buildagent\work\d3d49558e4d408f4\editor\src\gizmos\gizmomanager.cpp (261 + 0xb): GizmoManager::DrawAllGizmos + 0xa6
    9. (0x00E77E21) c:\buildagent\work\d3d49558e4d408f4\editor\src\utility\editorcameradrawing.cpp (859 + 0x0): Camera::FinishRenderingEditorCamera + 0x41
    10. (0x15423FD4) (Mono JIT code): (filename not available):  UnityEditor.Handles:DrawCameraStep2 (UnityEngine.Camera,UnityEditor.DrawCameraMode) + 0x64 (15423F70 15423FEB) [094B6BD0 - Unity Child Domain] + 0x0
    11. (0x15416D00) (Mono JIT code): (filename not available):  UnityEditor.SceneView:OnGUI () + 0x2b48 (154141B8 15417721) [094B6BD0 - Unity Child Domain] + 0x0
    12. (0x0C79BE1F) (Mono JIT code): (filename not available):  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (0C79BD90 0C79BEEA) [094B6BD0 - Unity Child Domain] + 0x0
    13. (0x0A04FEDE) c:\buildslave\monoandruntimeclasslibs\build\mono\mini\mini.c (4889 + 0xc): mono_jit_runtime_invoke + 0x214
    14. (0x09FBD680) c:\buildslave\monoandruntimeclasslibs\build\mono\metadata\object.c (2618 + 0x10): mono_runtime_invoke + 0x51
    15. (0x09FC24B9) c:\buildslave\monoandruntimeclasslibs\build\mono\metadata\object.c (3822 + 0x0): mono_runtime_invoke_array + 0x38b
    16. (0x09F8F465) c:\buildslave\monoandruntimeclasslibs\build\mono\metadata\icall.c (2856 + 0xe): ves_icall_InternalInvoke + 0x22e
    17. (0x0C77A488) (Mono JIT code): (filename not available):  (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception) + 0x90 (0C77A3F8 0C77A4C8) [094B6BD0 - Unity Child Domain] + 0x0
    18. (0x0C779330) (Mono JIT code): (filename not available):  System.Reflection.MonoMethod:Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) + 0x370 (0C778FC0 0C779418) [094B6BD0 - Unity Child Domain] + 0x0
    19. (0x0C834B95) (Mono JIT code): (filename not available):  System.Reflection.MethodBase:Invoke (object,object[]) + 0x4d (0C834B48 0C834BA0) [094B6BD0 - Unity Child Domain] + 0x0
    20. (0x0C860395) (Mono JIT code): (filename not available):  UnityEditor.HostView:Invoke (string,object) + 0x6d (0C860328 0C8603AC) [094B6BD0 - Unity Child Domain] + 0x0
    21. (0x0C8602FF) (Mono JIT code): (filename not available):  UnityEditor.HostView:Invoke (string) + 0x2f (0C8602D0 0C860316) [094B6BD0 - Unity Child Domain] + 0x0
    22. (0x153B7738) (Mono JIT code): (filename not available):  UnityEditor.DockArea:OnGUI () + 0x1f48 (153B57F0 153B7951) [094B6BD0 - Unity Child Domain] + 0x0
    23. (0x0C79BE1F) (Mono JIT code): (filename not available):  (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr) + 0x8f (0C79BD90 0C79BEEA) [094B6BD0 - Unity Child Domain] + 0x0
    24. (0x0A04FEDE) c:\buildslave\monoandruntimeclasslibs\build\mono\mini\mini.c (4889 + 0xc): mono_jit_runtime_invoke + 0x214
    25. (0x09FBD680) c:\buildslave\monoandruntimeclasslibs\build\mono\metadata\object.c (2618 + 0x10): mono_runtime_invoke + 0x51
    26. (0x00706EF8) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\mono\scriptingbackendapi_mono.cpp (183 + 0x1a): scripting_method_invoke + 0xb8
    27. (0x0082740C) c:\buildagent\work\d3d49558e4d408f4\runtime\scripting\backend\scriptinginvocationnoargs.cpp (97 + 0x0): ScriptingInvocationNoArgs::Invoke + 0x6c
    28. (0x006F60F7) c:\buildagent\work\d3d49558e4d408f4\runtime\mono\monobehaviour.cpp (401 + 0x0): MonoBehaviour::DoGUI + 0x1c7
    29. (0x00FF42A5) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\editorwindows.cpp (1961 + 0x0): GUIView::OnInputEvent + 0x155
    30. (0x00FF50EC) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\editorwindows.cpp (1197 + 0x1f): GUIView::DoPaint + 0x17c
    31. (0x00FF53A4) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\editorwindows.cpp (2232 + 0x0): GUIView::RepaintAll + 0x194
    32. (0x00F65664) c:\buildagent\work\d3d49558e4d408f4\editor\src\application.cpp (2337 + 0x0): Application::UpdateScene + 0x384
    33. (0x00F69577) c:\buildagent\work\d3d49558e4d408f4\editor\src\application.cpp (2216 + 0x0): Application::UpdateSceneIfNeeded + 0x37
    34. (0x0100C682) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\wineditormain.cpp (336 + 0x0): MainMessageLoop + 0x1c2
    35. (0x0100D5C7) c:\buildagent\work\d3d49558e4d408f4\editor\platform\windows\wineditormain.cpp (848 + 0x0): WinMain + 0xe37
    36. (0x01125C34) f:\dd\vctools\crt_bld\self_x86\crt\src\crt0.c (275 + 0x1c): __tmainCRTStartup + 0x11a
    37. (0x74E7336A) (kernel32): (filename not available): BaseThreadInitThunk + 0x12
    38. (0x77099F72) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x63
    39. (0x77099F45) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x36
    40.  
    41. ========== END OF STACKTRACE ===========
    42.  
    The crash only occurs when switching from a script that has OnDrawGizmos to a script that is lacking that method.
     
  2. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    I just opened up a new project in 4.3.4 and created 2 new scripts. In one of the scripts I added the OnDrawGizmos() function. I then attached one script to the camera and then continued switching the "Script" field between the two scripts by dragging and dropping. Unity never crashed. If you have a reproducible project with scripts, I suggest that you file a bug report with that project.
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Here you go, I submitted an empty project from that crash report that only has those 2 scripts.

    A few extra precision;

    1) Apply the WithGUI script to any empty object. I didn't add it to the Camera, and it shouldn't change anything.
    2) Be sure the item being drawn on the OnDrawGizmos() - the sphere or whatever - is visible on screen (SceneView).
    3) Change the script, I use the Object Picker dialog to change the script to the WithoutGUI one. I also tried it by dragging the script on the field, same crash.
    4) Crash!
     
  4. glennpow

    glennpow

    Joined:
    Jan 30, 2012
    Posts:
    56
    I also see this behavior. I must hide the Scene view, then replace the script, then save the prefab/scene, and then restart Unity. If I don't restart, then the next time I show the Scene it will crash.