Windows OpenXR + Unity segmentation fault on exiting play mode

Alexander Rupp-Coppi 1 Reputation point

TL;DR: Unity implements an OpenXR loader, which (because of something wrong with its xrNegotiateLoaderRuntimeInterface implementation) is fatally clashing at a very low level with the Windows Mixed Reality OpenXR runtime, resulting in a segfault fatal to the Unity editor.

Hi there,

I'm trying to get a Unity VR sample to run through OpenXR on my Windows Mixed Reality headset (a Samsung Odyssey).

Unity version: 2020.3.12.f1 LTS
Windows Mixed Reality runtime version: 106.2105.21002
WMR API: 1.0.16

Mixed Reality OpenXR Plugin 1.0.0
Unity OpenXR Plugin 1.2.3

I'm trying to run the sample demo 'Controller' optionally included with Unity's OpenXR plugin.

A couple of things happen when I try to enter, and then leave play mode in the Unity editor.

On Enter Play mode:

Most things initialize fine, but then:

[XR] [Mixed Reality OpenXR Mesh]: Lifecycle_Initialize.
[XR] [Mixed Reality OpenXR Mesh]: Not supported.
[Subsystems] Failed to initialize subsystem OpenXR Mesh Extension [error: 3]

This error doesn't seem to be fatal, because soon after:

[XR] [20660] [10:18:39.236][Info   ] OpenXRSession::HandleSessionStateChangedEvent: state XR_SESSION_STATE_IDLE->XR_SESSION_STATE_READY session=2 time=1160632301200

Suggesting OpenXR properly initialized (on the headset, the blue triangle transition screen opens up to show the four white orbs circling each other--but the orbs just circle indefinitely).

Since I'm getting a black screen in the editor game view and a loading screen in the headset, I click the play button to exit play mode.

The Unity editor then crashes and I get a request to submit a bug report.

The log from the fatal error, when Play mode is toggled:

[MODES] ModeService[default].RefreshMenus
[MODES] ModeService[default].UpdateModeMenus
Error on graphics thread: 1

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) UnityEngine.XR.OpenXR.OpenXRLoaderBase.Internal_EndSession () [0x00008] in <aa56b155af2d47fbbc2a0265118c4b6c>:0
  at UnityEngine.XR.OpenXR.OpenXRLoaderBase.StopInternal () [0x00041] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\com.unity.xr.openxr@1.2.3\Runtime\OpenXRLoader.cs:417
  at UnityEngine.XR.OpenXR.OpenXRLoaderBase.Stop () [0x0002c] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\com.unity.xr.openxr@1.2.3\Runtime\OpenXRLoader.cs:398
  at UnityEngine.XR.Management.XRManagerSettings.StopSubsystems () [0x00021] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Runtime\XRManagerSettings.cs:425
  at UnityEngine.XR.Management.XRManagerSettings.DeinitializeLoader () [0x00013] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Runtime\XRManagerSettings.cs:448
  at UnityEngine.XR.Management.XRGeneralSettings.DeInitXRSDK () [0x00021] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Runtime\XRGeneralSettings.cs:201
  at UnityEngine.XR.Management.XRGeneralSettings.Quit () [0x00010] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Runtime\XRGeneralSettings.cs:128
  at UnityEngine.XR.Management.XRGeneralSettings.InternalPlayModeStateChanged (UnityEditor.PlayModeStateChange) [0x00008] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Runtime\XRGeneralSettings.cs:112
  at UnityEditor.XR.Management.XRGeneralSettingsPerBuildTarget.PlayModeStateChanged (UnityEditor.PlayModeStateChange) [0x00033] in C:\Users\arcop\git\unity-xr-silence\HMD_Web_Demo_BRP\Library\PackageCache\\Editor\XRGeneralSettingsPerBuildTarget.cs:83
  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 <dc14d30a5e0540ee9311ed6df63d9074>:0
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_int (object,intptr,intptr,intptr) [0x00022] in <dc14d30a5e0540ee9311ed6df63d9074>:0
  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) UnityEditor.EditorApplication.set_isPlaying (bool) [0x00007] in <dc14d30a5e0540ee9311ed6df63d9074>:0
  at UnityEditor.EditorApplication.TogglePlaying () [0x00009] in <dc14d30a5e0540ee9311ed6df63d9074>:0
  at UnityEditor.UnityMainToolbar.DoPlayButtons (bool) [0x000ba] in <5f5866ec908d4054a9597064f39dbbac>:0

The editor tries to recover, but ends up hitting a segmentation fault, and crashes out completely:

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:
0x00007ffbaeed2640 (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaeed1f4d (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaee9bacb (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaee8b1a9 (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaeef338f (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaee5597d (WinXrRuntime) xrNegotiateLoaderRuntimeInterface
0x00007ffbaa191a86 (UnityOpenXR) session_EndSession
0x000001ebc7bc9251 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.XR.OpenXR.OpenXRLoaderBase:Internal_EndSession ()
0x000001ebc7bc8c2b (Mono JIT Code) [OpenXRLoader.cs:418] UnityEngine.XR.OpenXR.OpenXRLoaderBase:StopInternal () 
0x000001ebc7bc89b3 (Mono JIT Code) [OpenXRLoader.cs:400] UnityEngine.XR.OpenXR.OpenXRLoaderBase:Stop () 
0x000001ebc7bc891c (Mono JIT Code) [XRManagerSettings.cs:427] UnityEngine.XR.Management.XRManagerSettings:StopSubsystems () 
0x000001ebc7bc881b (Mono JIT Code) [XRManagerSettings.cs:449] UnityEngine.XR.Management.XRManagerSettings:DeinitializeLoader () 
0x000001ebc7bc877b (Mono JIT Code) [XRGeneralSettings.cs:202] UnityEngine.XR.Management.XRGeneralSettings:DeInitXRSDK () 
0x000001ebc7bc86c3 (Mono JIT Code) [XRGeneralSettings.cs:129] UnityEngine.XR.Management.XRGeneralSettings:Quit () 
0x000001ec278793ab (Mono JIT Code) [XRGeneralSettings.cs:119] UnityEngine.XR.Management.XRGeneralSettings:InternalPlayModeStateChanged (UnityEditor.PlayModeStateChange) 
0x000001ec27879333 (Mono JIT Code) [XRGeneralSettingsPerBuildTarget.cs:84] UnityEditor.XR.Management.XRGeneralSettingsPerBuildTarget:PlayModeStateChanged (UnityEditor.PlayModeStateChange) 
0x000001ec27864cd5 (Mono JIT Code) (wrapper delegate-invoke) System.Action`1<UnityEditor.PlayModeStateChange>:invoke_void_T (UnityEditor.PlayModeStateChange)
0x000001ec27864c04 (Mono JIT Code) UnityEditor.EditorApplication:Internal_PlayModeStateChanged (UnityEditor.PlayModeStateChange)

My hunch is that because the Windows OpenXR runtime is not properly initializing, when the Player makes a call to take back control from OpenXR, an invalid / null session is tried to be terminated, resulting in the segfault.

xrNegotiateLoaderRuntimeInterface fails several times before the actual fault.

From the OpenXR SDK docs:

Loader/Runtime Interface Negotiation

The OpenXR symbols exported by a runtime must not clash with the loader’s exported OpenXR symbols. Because of this, all runtimes must export only the following command with beginning with the xr prefix. This command is not a part of the OpenXR API itself, only a private interface between the loader and runtimes for version 1 and higher interfaces. In order to negotiate the loader/runtime interface version, the runtime must implement the xrNegotiateLoaderRuntimeInterface function (or a renamed version of this function identified in the manifest file).

More on loaders vs runtimes:

I may be understanding this wrong, but it seems that:

Unity implements an OpenXR loader, which (because of something wrong with its xrNegotiateLoaderRuntimeInterface implementation) is fatally clashing at a very low level with the Windows Mixed Reality OpenXR runtime, resulting in a segfault fatal to the Unity editor.

With that said, I should also get in touch with the Unity community, but if you have any pointers here I'm happy to hear them :)

Thank you!

HoloLens Development
HoloLens Development
HoloLens: A family of Microsoft self-contained, holographic devices that enable engagement with digital content and interaction with holograms in the surrounding environment.Development: The process of researching, productizing, and refining new or existing technologies.
380 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Yin Li (OLIVER) 6 Reputation points

    Thanks for building simpler project to test this crash. I read your new log, and i'm still puzzled on this crash.

    Unfortunately, unity's trace is cut too early due to the app fail to render frames. The "READY" state is a signal for unity to start frame loop but it seems never started due to lack of proper tracking: "Requested application space not available, falling back to local space". This is not fatal, but it didn't reach to the code for unity to dump diagnoses for runtime details. So we probably have to find other ways to find details.

    Since you are using an AMD graphics card, i suspect there's something abnormal that we typically didn't see in our dev teams.

    Here's my suggestion:

    1. Try to download this "dev tools" app from the Store, and run the "Demo Scene" here to see if your device is properly setup. Make sure you can see the demo scene in your headset and the headset is properly tracked through openxr here. And also try to click the "stop demo scene" button, to test the similar scenario to quit the session and closing down application. This demo scene is not a unity app. We can isolate if this is a problem below the runtime or inside unity.
    2. I'd like to get your dxdiag.txt log if it's ok for you to share.
    3. I think it might be good for you to give us a runtime trace for us to understand what's going on. This involves running the windows tracing service in admin prompt with a configuration for openxr runtime. I can share the details to you if you'd like to give this a try.
    4. There should be a "dmp" file for the crash in this folder "%LOCALAPPDATA%\Temp\Unity\Editor\Crashes". Could you zip this dump file and send it to us? Not sure if it helps, we can at least understand the crash stack with our symbol files.
    1 person found this answer helpful.

  2. Yin Li (OLIVER) 6 Reputation points

    @Alexander Rupp-Coppi Sorry for late reply. We've been making fixes in this area related to the "RUNTIME_FAILURE" at xrEndFrame(). It's a delicate problem on hybrid GPU and we don't have full confident it fixed your issue. We recently published a preview runtime 108.2109.10009. Please use the "openxr dev tools" to turn on "Preview runtime" and see if this solved the crashing issue you were seeing.


    0 comments No comments

  3. Yin Li (OLIVER) 6 Reputation points

    @Alexander Rupp-Coppi , The fixes related to this scenario has been released, have you tried latest versions and see if this still happen to you?

    • Latest Unity 2020.3.35f1 LTS
    • Latest Unity openxr plugin 1.4.2
    • Latest Mixed Reality openxr plugin 1.4.2
    • Latest OpenXR Runtime 110 (or preview 111).

    Let us know if you have further questions. Thanks

    0 comments No comments

  4. Yin Li (OLIVER) 6 Reputation points

    @Alexander Rupp-Coppi , There are a few issues in your report:

    1. The SIGSEGV log you added at the end of the report is because you don't have symbols for the dll. This xrNegotiateLoaderRuntimeInterface is the first exported function in the dll and therefore every "crash stack" is named as this function plus an offset. It doesn't represent the crash is related to this function.
    2. This trace "(UnityOpenXR) session_EndSession" indicate the crash happens when the session is shutting down. We have to see the heap dump to diagnose further on this issue. Could you please open a "Feedback hub bug" using "Mixed Reality" -> "Device" category? then send us your report Id:
    3. The "missing mesh subsystem" is correct message because the "mesh subsystem" is indeed not supported by VR system. It shouldn't affect what you are seeing.
    4. "show the four white orbs circling each other--but the orbs just circle indefinitely" This is not correct. Can you elaborate how run your app? Do you click the "play" button in Unity editor? or do you build and run the application as win32 app? or do you build a UWP app? Attaching a Unity trace will be helpful for us to help you.
    5. Building XR experience in unity can be sensitive to your project settings. It can be helpful if you following the instruction on the documentation:
      Or you can also clone our public sample and see if you can get the "BasicSample" app working first.
    6. As @Hernando Ren said, if you are building VR app using the Samsung Odyssey headset and targeting at "stand alone" platform (win32 exe app), then you don't need to include the "Mixed Reality features" in your project. But if you are using HP reverb G2 headset, or building UWP app then you'd better include it. From what you said, your project setting probably should be like this:

  5. Alexander Rupp-Coppi 1 Reputation point

    Hello! I made a fresh project, and disabled everything except for OpenXR (no custom windows XR packages are in the project).

    I have a new error (see the log):

    When the graphics thread crashes, the same error happens over and over, until the OpenXR runtime gives up and shuts down.

       [XR] [OpenXR Input]: Requested application space not available, falling back to local space  
       Error on graphics thread: 1  
       [XR] [OpenXR Input]: Application space recovered  
       [XR] [OpenXR Input]: Requested application space not available, falling back to local space  
       [XR] [OpenXR Input]: Application space recovered  
       [XR] [OpenXR Input]: Requested application space not available, falling back to local space  
       [XR] [OpenXR Input]: Application space recovered  

    Full log is attached.

    Current settings:


    I also updated the Windows Mixed Reality runtime to the preview release.

    And got the latest graphics driver for my pc.