Crash in XRDisplaySubsystem Destroy on PlayMode Exit??

I am getting a Unity crash on play mode exit.

My project has been stable and fine for months and nothing drastic has changed that would result in this crash. The issue started presenting shortly after I upgraded my Quest 2 to v32. I am not sure if it is related but this is my only lead so far.

I’m still in the process of narrowing it down and make sure it is not something on my end. Anyways, Unity crashes consistently 100% of the time on playmode exit .

I’m using Unity 2021.1.19f and latest version of XRI and XRManager packages. Also using the Oculus Plugin XR Integration.

From the stack dump, It looks to do with the DestroySubsystem of the XRDisplaySubsystem.

I tried creating an empty project with just the action based player right and the crash presents.

Just wondering if any one else has seen this recently or can point me the right direction. I’ve been scratching my head over this one.

Thanks for any insight/help!

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) UnityEngine.SubsystemBindings.DestroySubsystem (intptr) [0x00007] in <d4316ef652ed4f7aaafcee08b080979e>:0
  at UnityEngine.IntegratedSubsystem.Destroy () [0x00015] in <d4316ef652ed4f7aaafcee08b080979e>:0
  at UnityEngine.XR.Management.XRLoaderHelper.DestroySubsystem<T_REF> () [0x00035] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Runtime\XRLoaderHelper.cs:85
  at Unity.XR.Oculus.OculusLoader.Deinitialize () [0x00005] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.oculus@1.10.0\Runtime\OculusLoader.cs:201
  at UnityEngine.XR.Management.XRManagerSettings.DeinitializeLoader () [0x00027] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Runtime\XRManagerSettings.cs:443
  at UnityEngine.XR.Management.XRGeneralSettings.DeInitXRSDK () [0x00021] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Runtime\XRGeneralSettings.cs:201
  at UnityEngine.XR.Management.XRGeneralSettings.Quit () [0x00010] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Runtime\XRGeneralSettings.cs:128
  at UnityEngine.XR.Management.XRGeneralSettings.InternalPlayModeStateChanged (UnityEditor.PlayModeStateChange) [0x00008] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Runtime\XRGeneralSettings.cs:112
  at UnityEditor.XR.Management.XRGeneralSettingsPerBuildTarget.PlayModeStateChanged (UnityEditor.PlayModeStateChange) [0x00033] in C:\Users\frog\Dev\MyProject\Library\PackageCache\com.unity.xr.management@4.1.0\Editor\XRGeneralSettingsPerBuildTarget.cs:84
  at (wrapper delegate-invoke) System.Action`1<UnityEditor.PlayModeStateChange>.invoke_void_T (UnityEditor.PlayModeStateChange) [0x00070] in <695d1cc93cca45069c528c15c9fdd749>:0
  at UnityEditor.EditorApplication.Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange) [0x0001e] in <d04deee419f24e8faf312b86e53e3f07>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_int (object,intptr,intptr,intptr) [0x00022] in <d04deee419f24e8faf312b86e53e3f07>:0
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) UnityEditor.EditorApplication.set_isPlaying (bool) [0x00007] in <d04deee419f24e8faf312b86e53e3f07>:0
  at UnityEditor.EditorApplication.ExitPlaymode () [0x00002] in <d04deee419f24e8faf312b86e53e3f07>:0
  at UnityEditor.Toolbars.PlayModeButtons.OnPlayButtonValueChanged (UnityEngine.UIElements.ChangeEvent`1<bool>) [0x00016] in <937b2b5660994942a383daf774868ea5>:0
  at UnityEngine.UIElements.EventCallbackFunctor`1<TEventType_REF>.Invoke (UnityEngine.UIElements.EventBase) [0x00057] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.UIElements.EventBase) [0x00040] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase) [0x00054] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase) [0x0012f] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.DefaultDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel) [0x00025] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,bool) [0x00028] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel) [0x00047] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () [0x00039] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.OpenGate () [0x0003c] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcherGate.Dispose () [0x00007] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel) [0x0011a] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () [0x00039] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.OpenGate () [0x0003c] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcherGate.Dispose () [0x00007] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel) [0x0011a] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.IPanel,UnityEngine.UIElements.DispatchMode) [0x00049] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase,UnityEngine.UIElements.DispatchMode) [0x0001f] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel) [0x000e3] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&) [0x0003f] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.UIEventRegistration.ProcessEvent (int,intptr) [0x0001f] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.UIElements.UIEventRegistration/<>c.<.cctor>b__1_2 (int,intptr) [0x00003] in <3d389beb8fbc4cc99098812a324df20c>:0
  at UnityEngine.GUIUtility.ProcessEvent (int,intptr,bool&) [0x00018] in <8993825ca73141f8999b26a750e0f11a>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr) [0x0002d] in <8993825ca73141f8999b26a750e0f11a>:0
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Received signal SIGSEGV
Stack trace:

Okay, problem solved (at least for my particular instance). Here are my finding, just in case someone runs into a similar issue.

So I have integrated XR Plugin Manager with the Oculus Plugin and also the XR Interaction Toolkit. Separately, I have also integrated a portion of the Oculus Integration Asset. The Oculus Plugin was required to access the OVRPassthroughLayer that was introduced in v31 update the the Quest) as discussed here:

While initially working fine, this seems to have cause issue I was observing over time. Deleting the Oculus folder that was installed when the Oculus Integration Asset was imported solved the issue and the Unity no longer crashes on exit of play mode. I was able to reinstall the Oculus Integration Asset after and everything seems to work fine again.

Updated:
There is a bug filed for this one here:

Here’s a video on how to fix it: