Search Unity

Resolved VR does not initialize in editor or in standalone build

Discussion in 'VR' started by SPollari, Sep 8, 2021.

  1. SPollari

    SPollari

    Joined:
    Sep 8, 2021
    Posts:
    6
    EDIT - FIXED!

    The issue was that the default Active Runtime for OpenXR was set to Oculus. I had to go to registry and change it to SteamVR. I found it in HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenXR\1

    The SteamVR .json file was located at \Program Files (x86)\Steam\steamapps\common\SteamVR\steamxr_win64.json

    I set that in as the default and everything started to work normally.


    Original post starts here

    What would be the bare minimum requirement for a project to launch in a VR headset in the editor?

    I'm using a company computer, not my own. This has a bunch of things on it so I'm not sure what to look for exactly.

    I feel like my issue is trivial and might just be a check in a specific box, but I'm lost. I do have the "Initialize on startup" box checked in XR plug-in management. But it still doesn't start, even with SteamVR open already.

    The PC has HTC Vive Pro and I'm using latest (tried multiple) version of Unity. VR games work fine from Steam, and VR projects in Unity that have SteamVR plugin will initialize. I could use the SteamVR plugin, but it fills the list of XR controllers and XR HMDs so that it's a real hassle to find the one that actually works. And I would prefer to use OpenXR.

    I've tried following multiple tutorials for simple VR project setups and they don't work, so I feel like something is off on this computer, but I'm not sure what to look for or try. I did do the "lock input to game view".

    I tried on a different computer on here that has Oculus Rift, and it initializes fine in Unity. So it feels like this computer has issues and would love to know what it is.

    Any help would be appreciated.
     
    Last edited: Sep 8, 2021
  2. TomasMcKenna

    TomasMcKenna

    Joined:
    Feb 18, 2020
    Posts:
    5
    Brilliant, thanks for posting this, had the same issue with the registry set to C:\Windows\system32\MixedRealityRuntime.json. It was driving me nuts.
     
    SPollari likes this.
  3. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    Sadly this doesn't work for me. I have both a VIVE Pro and HP Reverb G2 and neither will initialize XR regardless of whether I'm using WMR or SteamVR.

    The stupid thing is I have OpenXR selected as a package, and have tried with and without the WMR feature group.

    Update
    The Editor Log indicates:
    Code (CSharp):
    1. [XR] [2976] [10:23:24.562][Info   ] OpenXRSession::HandleSessionStateChangedEvent: state XR_SESSION_STATE_UNKNOWN->XR_SESSION_STATE_IDLE session=1911828067824 time=66785806864800
    2. [XR] [2976] [10:23:24.562][Info   ] OpenXRSession::HandleSessionStateChangedEvent: state XR_SESSION_STATE_IDLE->XR_SESSION_STATE_READY session=1911828067824 time=66785806874400
    3. [XR] [2976] [10:23:24.562][Error  ] xrRequestExitSession: XR_ERROR_SESSION_NOT_RUNNING
    4. [XR] [2976] [10:23:24.563][Info   ]
    I have the checkbox for Initialize XR on Startup checked, so why no Initialization... I miss the previous (sadly short-lived) 2019.2 VR solution.

    Update 2 - Success
    I started a 100% fresh project re-tracing all of my steps and OpenXR just worked, for both SteamVR and WMR. Comparing the packages of that project to my current project identified a few minor differences.

    Once I nuked the XRInteractionToolkit package (https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@1.0/manual/index.html) OpenXR started initializing XR again. As an added bonus the Convert main camera to XRRig option came back too.

    Stay away from the XRInteractionToolkit package! It's an abomination and has cost me approx. 16 hours of my life that I'll never get back troubleshooting the upgrade.

    Side Note: There appears to be an incompatibility with the new OpenXR render pipeline and graphics.Blit. If you get a stuck HMD image, or if one eye is a solid color (white for me) and the other is frozen or black. Check your post processing effects by disabling them.
     
    Last edited: Jun 30, 2022
  4. Lister6520

    Lister6520

    Joined:
    Dec 1, 2017
    Posts:
    3
    I'm having a similar problem that's driving me crazy. I'm using WMR with a Lenovo Explorer headset. I have previously made apps in Unity with WMR and this same headset and those still work, both in editor and built.
    The problem is that it only works in Unity versions up to 2018. In later versions the MRTK I have doesn't work - it generates all sorts of errors and won't even build.
    So I tried using the MRTK2 and even MRTK3 packages with the later Unity versions. I followed the Unity user manual, the MRTK user manual and many tutorials, both articles and Youtube Videos but I still cannot get I to work. I get one of two outcomes - either it doesn't build because of errors such as missing packages and so on or else it builds without errors but when I press the play or I build and run it does not work.
    What it does is briefly activate VR but never displays anything. If VR is not already active it lights up the headset, goes through the usual initializing but when ready it just falls into the cliff house instead of displaying the content from unity. If I am already in Cliff House then it does that visual effect of when entering a VR app and almost immediately does the other effect of when exiting VR and I am back in the cliffhouse. In the meantime the app continues running in the player, but just on the monitor. The tracking is also never activated.
    At first I thought I just didn't know how to do it, but after following so many tutorial I'm pretty sure I haven't missed anything. I even downloaded ready made example projects and they don't work either, failing in exactly the same way.
    I think there must be something wrong on my laptop but I don't know where to even begin.

    Any ideas what I can try to do?
     
  5. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    Over the last 3 months We've learnt not to use any version of unity newer than 2018 LTS, and to stay far, far away from URP if one can. There's just far too many inconsistencies, incompatibilities, incomplete systems, and other nightmare level issues that have caused us to waste the last 3 months re-engineering a large portion of the application.

    I'm not familiar with the new MRTK packages as I haven't used them in a while, so can't help there. That said, you can try the following things:
    1. If you can revert to 2018 LTS and save yourself the pain that is around the corner as a large number of things have breaking changes and painful workarounds!
    2. Triple check the "Play Mode OpenXR Runtime" is set according to your currently assigned runtime in the registry. (I debug with multiple runtimes and headsets so I'm always changing it, which has caught me in the past.)
    3. Make sure that only the game view tab is visible/selected when launching, then after the system is initialized, you can select the Scene tab, but be wary of having them both visible at the same time.
    4. 2019 or 2021 version had a 'Focus' game view option on the tab's header, that has to be set appropriately before play is pressed or OpenXR would fail to initialize. (2022 seems to have removed it/defaulted it)
    5. Disable any CommandBuffer/RenderFeature effects you may have.
    6. If you were using the Built-In pipeline, and now have the URP pipeline or HDRP pipeline selected, you will need to roll that back. There are a whole series of package dependencies that will need to be addressed.
    Sorry it's not much help.
     
  6. Lister6520

    Lister6520

    Joined:
    Dec 1, 2017
    Posts:
    3
    Thanks for the help, very much appreciated. I still haven't managed to get it to work but I haven;t yet done all the things you suggested, so there is still hope.
    Point 2: I checked the openXR runtime which was correct in the registry (Windows mixed Reality) but in the Project settings it was System default, so I fixed that but unfortunately it made no difference.
    Point 3: I confirm only the game view tab is visible. Also, the problem also occurs in the same way in the built app (ie not running from the editor)
    Point4: I haven't found the 'Focus' setting yet
    Points 5 & 6 I still need to understand better what these are. I am not aware of having changed any of these but I will try to find what they are set to.

    Note the problem is not limited to porting from an older Unity to a newer one but even creating a new project from scratch in the newer versions. Even an example I downloaded from Microsoft doesn't work.

    For the life of me I cannot understand why everything has become so broken and complicated and it makes me wonder how almost everyone else is coping.

    It seems to me that one should be able to just tick a box saying 'Enable VR', and perhaps select the VR headset type, and it should work. In the past it was almost like that as one just had to import the MRTK package and click two options in the MRTK menu and it would get everything going. Now it has become a long and tedious process with settings scattered all over the place that one has to be careful to set correctly and at the end of that it doesn;t even work.

    I guess in the end I may have to stay with your first suggestion and just stay in 2018 as long as possible.
     
  7. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    This post shows where it was. If it's no longer there then you it was patched by Unity for your version.
     
  8. Lister6520

    Lister6520

    Joined:
    Dec 1, 2017
    Posts:
    3
    Gosh that's embarrassing, I do have that setting but somehow I was not seeing it even right there in front of my eyes until you pointed it out. I have now tried all three settings - focused, unfocused and maximized and also tried as you said in other post to select the play tab and then the play button but I keep getting the same thing - it enters VR then exists VR immediately.

    I had a different result with the unfocused, at least initially, it would do the usual fragments effect to get into VR but instead of exiting immediately I get the four spinning white balls, sort of the VR equivalent of the hour glass cursor. It seems to stay there forever though, never proceeding to show me the actual scene. It only stops when I click the Unity icon in the taskbar to bring Unity in the foreground, at which point VR exits but the scene keeps running in the Game tab.

    I still haven't figured out the pipeline thing. The closest I found, though possibly just in name, is HDR in the camera object. This is by default 'Graphics setting' and I changed it to OFF, which is the only other option. Right below it is MSAA, which I understand is related to HDRP, so I tried changing that from 'Graphics Settings' to OFF but still no luck.

    What I don't understand is how there are so many Youtube videos that show how to make it work and despite following them as closely as I can to replicate exactly what they are doing I just cannot get it to work. I'm not even trying to migrate an existing project from an older version but just following tutorials to set up a new one. There must be something wrong with my laptop, or maybe with me, as I seem to be the only one, or perhaps one of very few who cannot make it work even at the most basic level. The thing is though that up to 18.4 and the old MRTK it works fine whereas with MRTK2 & 3 don't work in any version of Unity and the original MRTK works only up to 18.4. Unfortunately I don't have another laptop or PC that passes the Windows MR compatibility test.
     
  9. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    @Lister6520 I wouldn't blame your setup right off the bat. There's several deficiencies with the new(er) unity versions and packages that are not exactly straightforward to identify/resolve. There's also some with Windows Mixed Reality (WMR) issues about. YouTubers also rarely if ever re-visit a topic to update it for the latest versions idiosyncrasies.

    The SRP pipeline settings asset is where any RenderFeatures would be found for URP/HDRP. (Edit > Project Settings > Graphics > 'click on the top field' to locate the asset.)

    If you're also using SteamVR, there is an incompatibility I've noted between the WMR Portal (WMR) and SteamVR that can causes crashes. This is evident when SteamVR (with the WMR plugin for SteamVR) is launched before the Mixed Reality Portal is launched. If you use both, like I do here, you'll need to let WMR trigger SteamVR on it's own accord, or not at all as it's not required.

    Additionally, verify the WMR portal '...' > 'Settings' > Startup and Desktop' checkboxes are all un-checked then restart and manually launch the WMR portal to rule out a local system conflict with auto-detection & launch.

    Outside of that, you'll likely need to ping a Unity Dev and submit a package to the bug portal to get them to take a look. I know it was a pain for me to get it to play nicely when I updated, but have been fighting so many other issues that I've mostly forgotten what I did to get it to work.
     
  10. filkata123

    filkata123

    Joined:
    Apr 30, 2023
    Posts:
    1