Search Unity

Bug OpenXR plugin tries to start VR even if Initialize on startup is set to false (UWP)

Discussion in 'VR' started by demonixis, Mar 6, 2023.

  1. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Hello,
    I'm facing a serious problem with the OpenXR plugin on my UWP project.
    I want to enable VR only if user want it. That's what I do on the Windows Target and it works fine.
    On UWP builds, the plugin tries to start the VR session even if initialize on startup is set to false.

    The problem is that for the end user, it's a black screen is the headset is not connected. I can't validate the application on the store too.

    Is there a settings or anything I can try as a workarround?
     
  2. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    How are you calling this? For me it works simply by having this as an optionable button to activate and deactivate.
    Start: XRGeneralSettings.Instance.Manager.StartSubsystems();
    Stop: XRGeneralSettings.Instance.Manager.StopSubsystems();
     
  3. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Yes this is what I do when I want to manually start VR.
    But on UWP it starts automatically on my builds even if the checkbox Initialize XR on startup is unchecked
     
  4. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    Could you show me how you initialize and stop VR in your startup/load script?
     
  5. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Hey,
    Here is the code I use. However I DON'T call this code during initialization. My problem is not related to this code. Please read the description of my problem.

    Code (CSharp):
    1. public static void TryInitialize()
    2.         {
    3.             var manager = XRGeneralSettings.Instance.Manager;
    4.  
    5.             if (manager.activeLoader != null)
    6.             {
    7.                 return;
    8.             }
    9.  
    10.             manager.InitializeLoaderSync();
    11.             manager.StartSubsystems();
    12.         }
    13.  
    14.         public static void TryShutdown()
    15.         {
    16.             var manager = XRGeneralSettings.Instance.Manager;
    17.  
    18.             if (manager.activeLoader == null)
    19.             {
    20.                 return;
    21.             }
    22.  
    23.             manager.DeinitializeLoader();
    24.             manager.StopSubsystems();
    25.         }
     
  6. nilagard

    nilagard

    Joined:
    Jan 13, 2017
    Posts:
    77
    I see, I read it again and I know of that problem. Unity force awakens VR before anything else is allowed to run. It's forced before awake & start and anything else, even if disabled. If you want to disable just that thing then I do not have the solution for you at this point. But you can try and google around to try to find it, or open a bug ticket and get an answer from a dev. I am sure this is just a bug and not intentional, there should be a more easy solution if you want this on or off.
     
  7. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    This looks like a bug. Can you submit one and post it here? We'll investigate.

    Details: before unity creates the graphics device, if there's even a chance of enabling VR, we have to startup VR and ask which graphics adapter to start up on (ie: in the case of multiple graphics cards on a machine). It looks like we're not properly shutting that down in order to allow non-vr mode to start up.
     
  8. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    @thep3000 CASE IN-34454. I created a repro project using the VR template. If you build it you've the problem.
     
    nilagard likes this.
  9. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Thanks, we'll look into it.
     
  10. demonixis

    demonixis

    Joined:
    Aug 20, 2013
    Posts:
    185
    Hello,
    Have you an ETA for a fix please? This bug preventing us to update two games on the Microsoft Store.
    Best,