Unity 6.0.27f1, XRITK 3.0.7, main loop freeze when XR Rig is disabled

TL;DR version: “Start with XR” enabled causes main loop to freeze somewhere; Update() only called once.

I ran in to an issue that I believe is a bug with the startup of the XR subsystem. I have a working 2022.3 project out in GitHub at GitHub - Corysia/Unity_VR_Examples: A collection of VR Examples that has a scene called “Pancake”. In this demo project, I’m showing how it is possible to try to detect whether or not a HMD is attached to the system. If it isn’t, the XR Rig is set inactive and another camera is made active. This is handled in DetectVR.cs

There are enough changes between Unity 2022.3 and the XRITK 2.4.3 and today’s Unity 6.0.27f1 and XRITK 3.0.7, that I wasn’t able to simply upgrade this project. I started working on a new version from scratch and found that if I disable my XR Rig and enable my desktop camera, the Update() method of every one of my scripts is only called once and never again.

It’s been difficult to debug this. No exception is thrown and the only error I’ve seen has been one I expect to see when running on a Mac:

Failed to load openxr runtime loader.
UnityEngine.XR.Management.XRGeneralSettings:AttemptInitializeXRSDKOnLoad () (at ./Library/PackageCache/com.unity.xr.management/Runtime/XRGeneralSettings.cs:148)

Windows doesn’t present any errors, so I don’t believe this error is related to the problem.

I’ve tried to trace this thru with a debugger, but it eventually hits code I don’t have source for and I lose my place.

I’ve created a demo project to illustrate this bug. GitHub - Corysia/Pancake: This is a demo project for showing how to start up a Unity game in either VR or Desktop – note this is a git lfs project, so you’ll need to clone it, don’t simply grab a zip as that won’t work.

Well, with further testing and confirmation from a friend, it does seem to be working in Windows as expected. So it is just on the Mac that the thread locks up.

I’ve updated Assets/Scene/SampleScene to illustrate the problem better. I had been using the DemoScene out of the XRITK and that was more difficult to drill down to.

And…a little more testing, when building an OSX Pancake.app, it appears to be working fine, too. So, it is just in the Unity Editor that this bug is happening.

So…

  1. It works in Windows when building an EXE
  2. It works in Windows when running from the Editor
  3. It works on OSX when running from a built app.

BUT…

  1. It does not work when running on OSX in the Editor.

So…after more testing, I believe this bug is in the OpenXR library.

Here’s the corner case:

This bug occurs only on a Mac, only when playing in the editor, only when “Initialize XR on Startup” is checked, and only with OpenXR used. Oculus is fine.

Adding the Unity Mock HMD doesn’t help.