We’ve been getting some very odd behavior lately that I’ve been trying to track down.
- Depending on where it happens in our code, sometimes a C# Null Reference Exception will interrupt execution of the script but the game will keep running, in other places it will kill the process entirely.
- The stack traces we get are often a single line or lost entirely. This appears to happen frequently where we run into a case where the process is killed by an exception. The stack is the same in Unity Performance Monitoring, Crashlytics, and Google Analytics.
When trying to diagnose the above problem, I ran into something else that was very weird. I set up a script to trigger a Null Reference Exception when pushing a button. The stack trace in the editor looks like you would expect:
NullReferenceException: Object reference not set to an instance of an object
LockerRoom.OnButtonClickedPlay () (at Assets/Game/LockerRoom/LockerRoom.cs:315)
UnityEngine.Events.InvokableCall.Invoke (System.Object[ ] args) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent.cs:153)
UnityEngine.Events.InvokableCallList.Invoke (System.Object[ ] parameters) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent.cs:634)
UnityEngine.Events.UnityEventBase.Invoke (System.Object[ ] parameters) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent.cs:769)
UnityEngine.Events.UnityEvent.Invoke () (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:53)
UnityEngine.UI.Button.Press () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35)
UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44)
UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:52)
UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
UnityEngine.EventSystems.EventSystem:Update()
However, when running on device and attached to Xcode, I get a bunch of things in the stack trace that make no sense:
NullReferenceException: A null value was found where an object instance was required.
at AdColony.Awake () [0x00000] in :0
at LockerRoom.OnButtonClickedPlay () [0x00000] in :0
at UnityEngine.Events.UnityAction.Invoke () [0x00000] in :0
at UnityEngine.Events.InvokableCall.Invoke (System.Object[ ] args) [0x00000] in :0
at NetworkStateDispatcher.OnPhotonJoinRoomFailed (System.Object[ ] codeAndMsg) [0x00000] in :0
at UnityEngine.Events.InvokableCallList.Invoke (System.Object[ ] parameters) [0x00000] in :0
at UnityEngine.Events.UnityEventBase.Invoke (System.Object[ ] parameters) [0x00000] in :0
at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in :0
at UnityEngine.UI.Button.Press () [0x00000] in :0
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in :0
at UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerExitHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in :0
at UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in :0
at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (.T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in :0
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in :0
at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released) [0x00000] in :0
at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in :0
at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in :0
at CodeStage.AntiCheat.Detectors.ActDetectorBase.OnEnable () [0x00000] in :0
at UnityEngine.EventSystems.EventSystem.Update () [0x00000] in :0
What are AdColony, Photon, and the AntiCheat stuff doing in that stack trace? They’re no where in the call chain. It’s like there’s a nasty bug where the symbols and the code don’t match up so it’s getting all kinds of garbage. I’m wondering if this is just another symptom of the things causing my original issues. Has anyone ran into these types of problems before?
Oh yeah … deleted Library before building and was a clean Xcode project (not appended).
Thanks a bunch!
Tom