Editor Crash when applying change on prefab that using abstract SerializedMonoBehaviour and contains a component with UnityEvent field

Issue #280 resolved
PuzzledBoy created an issue

Comments (12)

  1. Bjarke Elias
    • changed status to open

    Thanks for reporting btw.

    We've actually looked into this one multiple times, and all we've found out so far it could be tied to Unity's Undo system. Going to continue my investigation now.

  2. Bjarke Elias

    Small update.

    The call stack of the crash: (It's a bug within the Unity that is triggered somehow with custom prefab modifications, if a UnityEvent is present on a seperate component).

    0x0000000141418A46 (Unity) WalkTypeTree
    0x0000000141418C5F (Unity) WalkTypeTree
    0x0000000141418C5F (Unity) WalkTypeTree
    0x0000000141418B4F (Unity) WalkTypeTree
    0x0000000141418C5F (Unity) WalkTypeTree
    0x0000000141418C5F (Unity) WalkTypeTree
    0x0000000141418C5F (Unity) WalkTypeTree
    0x00000001406AD20F (Unity) ApplyPropertyRecurse<UpdatePrefabModificationToCurrentState>
    0x00000001406C0F96 (Unity) GeneratePrefabPropertyDiff
    0x00000001406C3EBD (Unity) RecordPrefabInstancePropertyModifications
    0x00000001406C3EF2 (Unity) RecordPrefabInstancePropertyModificationsAndValidate
    0x00000001401FAB71 (Unity) SceneTracker::FlushDirty
    0x000000014010E724 (Unity) Application::UpdateSceneIfNeeded
    0x000000014013264F (Unity) Application::TickTimer
    0x0000000141A9210D (Unity) MainMessageLoop
    0x0000000141A93A1E (Unity) WinMain
    0x0000000141CF7DCC (Unity) __tmainCRTStartup
    0x00007FFAAFF51FE4 (KERNEL32) BaseThreadInitThunk
    0x00007FFAB008EFB1 (ntdll) RtlUserThreadStart
    
    public class NewBehaviourScript : SerializedMonoBehaviour
    {
        [NonSerialized, OdinSerialize, CustomValueDrawer("DrawAndSleep")]
        public int a;
    
        private int DrawAndSleep(int val, GUIContent label)
        {
            EditorGUI.BeginChangeCheck();
            val = Sirenix.Utilities.Editor.SirenixEditorFields.IntField(label, val);
            if (EditorGUI.EndChangeCheck())
            {
                // Sleeping for a bit after each modification does seem to fix the problem.
                // Which indicates that it *maybe* could be a multi-threading issue within Unity.
                // Out-commenting this will result in a crash when modifying the value quickly (by dragging the label).
    
                Thread.Sleep(100);
                // Sleeping for 10, doesn't seem to be enough to fix it on my machine. It needs to be a 100.
            }
            return val;
        }
    }
    
    
    public class AUnityEvent : MonoBehaviour
    {
        public UnityEvent unityEvent;
    
        // Since it could be a multithreading issue, I tried simply adding a lot of data, without the UnityEvent.
        // But that did not trigger any crashes either. So far it seems to only trigger the crash if the UnityEvent is present 
        // in a another component on the same game object. 
        // public int abcdefg, abcdegf, abcdfeg, abcdfge, abcdgef, abcdgfe, abcedgf, abcedfg, abcefgd, abcefdg, abcegfd, abcegdf, abcfdeg, abcfdge, abcfedg, abcfegd, abcfgde, abcfged, abcgdfe, abcgdef, abcgefd, abcgedf, abcgfed, abcgfde, abdcgef, abdcgfe, abdcegf, abdcefg, abdcfge, abdcfeg, abdegfc, abdegcf, abdecfg, abdecgf, abdefcg, abdefgc, abdfgce, abdfgec, abdfcge, abdfceg, abdfegc, abdfecg, abdgfec, abdgfce, abdgcef, abdgcfe, abdgecf, abdgefc, abecfgd, abecfdg, abecgfd, abecgdf, abecdfg, abecdgf, abedfcg, abedfgc, abedgcf, abedgfc, abedcgf, abedcfg, abefdgc, abefdcg, abefgdc, abefgcd, abefcdg, abefcgd, abegdcf, abegdfc, abegfcd, abegfdc, abegcfd, abegcdf, abfcdeg, abfcdge, abfcedg, abfcegd, abfcgde, abfcged, abfdcge, abfdceg, abfdegc, abfdecg, abfdgec, abfdgce, abfecdg, abfecgd, abfedcg, abfedgc, abfegcd, abfegdc, abfgced, abfgcde, abfgdec, abfgdce, abfgedc, abfgecd, abgcfde, abgcfed, abgcdfe, abgcdef, abgcefd, abgcedf, abgdfec, abgdfce, abgdcef, abgdcfe, abgdecf, abgdefc, abgefcd, abgefdc, abgecfd, abgecdf, abgedfc, abgedcf, abgfedc, abgfecd, abgfcde, abgfced, abgfdce, abgfdec, acbgefd, acbgedf, acbgfed, acbgfde, acbgdef, acbgdfe, acbdegf, acbdefg, acbdfge, acbdfeg, acbdgfe, acbdgef, acbedfg, acbedgf, acbefdg, acbefgd, acbegdf, acbegfd, acbfdge, acbfdeg, acbfegd, acbfedg, acbfged, acbfgde, acdgbef, acdgbfe, acdgebf, acdgefb, acdgfbe, acdgfeb, acdbgfe, acdbgef, acdbefg, acdbegf, acdbfeg, acdbfge, acdegbf, acdegfb, acdebgf, acdebfg, acdefgb, acdefbg, acdfgeb, acdfgbe, acdfbeg, acdfbge, acdfebg, acdfegb, acegfbd, acegfdb, acegbfd, acegbdf, acegdfb, acegdbf, acebfdg, acebfgd, acebgdf, acebgfd, acebdgf, acebdfg, acedfgb, acedfbg, acedgfb, acedgbf, acedbfg;
    }
    
  3. Bjarke Elias

    We've managed to finally find a simple solution for the crash. I'm not sure why it solves the issue, but it does. And thrown a lot of test cases after it, and so far we haven't been able to cause it to crash or give us any other issues. Would you be willing to test a hotfix as well, and confirm that it also works for you?

    If you could shoot us a message from our website with your Odin invoice ID, we'll send you the hotfix.

    Thanks again.

  4. PuzzledBoy reporter

    Oh, I'm willing to test it. I will send a email from the Odin website with my invoice number,please wait a minute.

  5. PuzzledBoy reporter

    I unable to access the email account that purchase the plugins for some reason, I'm finding another way to get the invoice id. if I already send the email ,I will reply here to let you know. Thank you.

  6. PuzzledBoy reporter

    It works good in my situations, for now. I will keep tracking any potential issues comes out in the future.

    Thanks you a lot.

  7. PuzzledBoy reporter

    Hi, a new issue found of the hotfix version.

    Steps:

    • Create a new Scene.
    • Create a new Script
        public class TestOdin : SerializedMonoBehaviour
        {
            public DataBase data;
        }
    
        public abstract class DataBase
        {
            public GameObject go;
        }
    
        [Serializable]
        public class Data1 : DataBase
        {
    
        }
    
    • Create an empty GameObject1,add the Script "TestOdin" to it.
    • Create another empty GameObject2, assign it to the field "go" at GameObject1.
    • Drag GameObject1 to project window to create a prefab.
    • Click the GameObject1 at scene,the field "go" lost it's reference.

    Test Unity version 2017.2.1p3, seem a new issue remains after the #280 fixed.

    Thanks.

  8. Log in to comment