windows-mixed-realityopenxr

When my Windows Mixed Reality googles go to sleep OpenXR gets an exit state change


I am writing an application using OpenXR on Windows using the Windows Mixed Reality OpenXR addon/plugin. When my application runs and the VR device goes to sleep, I get a state change to exit the OpenXR application. According to the OpenXR lifecycle there's no way back (and I properly exit my application). I can wake up the glasses in the Mixed Reality Portal. Even if I ignore the exit state change in my application and keep it running, after waking up the glasses I don't get any state-changing events in my OpenXR application. Is this the correct behaviour? I assumed I need to properly handle going to sleep in my application (pause the application for example and continue on waking up the device). Is there something else I am missing?

Here are the state changes I recorded (just starting the application and waiting for the VR device to go sleep):

- XR_SESSION_STATE_IDLE
- XR_SESSION_STATE_READY
- XR_SESSION_STATE_SYNCHRONIZED
- XR_SESSION_STATE_VISIBLE
- XR_SESSION_STATE_SYNCHRONIZED
- XR_SESSION_STATE_STOPPING
- XR_SESSION_STATE_IDLE
- XR_SESSION_STATE_EXITING

so the actual question is: How do I properly handle VR devices going to sleep when using OpenXR with Windows Mixed Reality?

Thanks for any hints :)


Solution

  • Thanks for the comments and updates. For the behavior, this is correct for XR_SESSION_STATE_EXITING being sent before closure. There is not a resume state or suspend state in OpenXR spec:

    https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSessionState.html

    XR_SESSION_STATE_EXITING.

    "The application should end its XR experience and not automatically restart it."

    So, if you do have any clean-up that you want to perform for the application, you can do that piece when receiving: XR_SESSION_STATE_STOPPING

    Upon re-launching, you should get the standard XR_SESSION_STATE_READY notification again to do any application specific startup. That could be reading status from storage, web service, etc. There was an issue that was fixed for resume and rendering but as noted in comments, this has been fixed