Search Unity

Resolved OpenXR requires restarting SteamVR between each play mode in the editor

Discussion in 'VR' started by emrys90, May 27, 2021.

  1. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    I'm having an issue where I have to restart SteamVR each time I reenter play mode in the editor. If I don't, then the game never loads into VR. Just has the endless steam little popup in the home screen of it loading. Any ideas how to resolve this? This didn't happen before I updated to 2020.3 to switch to OpenXR.
     
  2. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    I switched to Oculus as the default OpenXR provider, and still running into the same kind of issues. It's frequently making me have to restart Unity as well, and Unity starts so much slower in 2020.3 than it did in 2019.4. This is going to affect my productivity majorly :/

    EDIT:
    And now Unity is also crashing often when trying to reenter play mode. Any ideas on how to resolve all these issues?
     
    Last edited: May 27, 2021
  3. SpaceOwlGames

    SpaceOwlGames

    Joined:
    Apr 22, 2016
    Posts:
    61
    I had similar issues, for some reason OpenXR + SteamVR as runtime loses connection to Unity whenever the headset is asleep, this would even happen during scene loads if it lags out for a few seconds, it would just never return. The solution was to periodically poll if the device is active and then restart the XR manager.
    https://www.reddit.com/r/learnVRdev/comments/netvkz/how_to_restart_xrloader_vive_headset_tracking/

    Code (CSharp):
    1. void Update(){
    2. if (timeoutcheck <= 0) {
    3.             if (!XRSettings.isDeviceActive) {
    4.                 StartCoroutine(RestartXRCoroutine());
    5.             }
    6.             timeoutcheck = 2f;
    7.         }
    8.         timeoutcheck -= Time.deltaTime;
    9. }
    10.  
    11. public IEnumerator RestartXRCoroutine() {
    12.         StopXR();
    13.         Debug.Log("Initializing XR...");
    14.         yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
    15.  
    16.         if (XRGeneralSettings.Instance.Manager.activeLoader == null) {
    17.             Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    18.         } else {
    19.             XRGeneralSettings.Instance.Manager.StartSubsystems();
    20.             Debug.Log($"Starting XR...{XRGeneralSettings.Instance.Manager.activeLoader.name} - {XRGeneralSettings.Instance.Manager.isInitializationComplete}");
    21.         }
    22.     }
    23.  
    24.     void StopXR() {
    25.         Debug.Log("Stopping XR...");
    26.  
    27.         XRGeneralSettings.Instance.Manager.StopSubsystems();
    28.         XRGeneralSettings.Instance.Manager.DeinitializeLoader();
    29.         Debug.Log("XR stopped completely.");
    30.     }
    Not sure if this is an issue with OpenXR, SteamVR or Unity, but I hope they fix this cause this is janky AF.
     
  4. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    That fixed it, thank you so much! It was driving me crazy
     
  5. SpaceOwlGames

    SpaceOwlGames

    Joined:
    Apr 22, 2016
    Posts:
    61
  6. emrys90

    emrys90

    Joined:
    Oct 14, 2013
    Posts:
    755
    Awesome, thank you!