Search Unity

Question XR Plugin Management Initialize on Startup

Discussion in 'VR' started by IElectric, Jan 31, 2020.

  1. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Hello, I'm using the new XR system, on my UWP game I have disable the option Initialize on Startup but in the final UWP master build the VR start Always when the game started, I don't know why.
    In the Unity editor works properly and VR doesn't start on game start, thank you, Best regards…

    Universal Windows Platform
    Visual Studio 2017 community Version 4.8.03752
    Unity 2019.3.0f6
    new XR system
     
    Last edited: Nov 27, 2020
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Can you file a bug report and post the issue here? Thanks.

    As a workaround, in your VS project open the boot.config file and change early-boot-windows-holographic=1 to early-boot-windows-holographic=0.
     
  3. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Yes, with the boot.config modification the VR doesn't start when the game start, but the code to enable XR at Runtime doesn't works, in the Unity editor the same code to enable/disable XR works properly, thank you, Cheers...

    Code (CSharp):
    1.     private void EnableVisor()
    2.     {
    3.       UnityEngine.XR.Management.XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
    4.  
    5.       UnityEngine.XR.Management.XRGeneralSettings.Instance.Manager.StartSubsystems();
    6.     }
    7.     private void DisableVisor()
    8.     {
    9.       UnityEngine.XR.Management.XRGeneralSettings.Instance.Manager.StopSubsystems();
    10.  
    11.       UnityEngine.XR.Management.XRGeneralSettings.Instance.Manager.DeinitializeLoader();
    12.     }
    View attachment 552921
     
    Last edited: Nov 27, 2020
    Ryuuguu likes this.
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Please file a bug and we'll look into it.
     
  5. iLyxa3D

    iLyxa3D

    Joined:
    Sep 25, 2013
    Posts:
    31
    Use coroutines to init XR:
    Code (CSharp):
    1.  public IEnumerator InitXR()
    2.     {
    3.         yield return  XRGeneralSettings.Instance.Manager.InitializeLoader();
    4.     }
    Simple "XRGeneralSettings.Instance.Manager.InitializeLoader();" did not work.
     
    dwipayana24071995 and IElectric like this.
  6. iLyxa3D

    iLyxa3D

    Joined:
    Sep 25, 2013
    Posts:
    31
    Can anybody tell, why camera image freeze after return to 2d mode by "XRGeneralSettings.Instance.Manager.StopSubsystems();" ?
     
    joanpescador likes this.
  7. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    215
    Hi, thank you very much for your suggestion, at this time I'm using a deprecated WMR package but soon I will update my project to use the new XR system, Cheers...
     
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    Also @joejo those docs have been obviously wrong in this topic for months (still are). I've asked 2 or 3 times of Unity staff on these forums what the correct docs should be, and I've so far been ignored every time, which is disappointing.

    1. It says "to add/create, remove, reorder ... use these methods" ... none of those methods add, none of them create, and none of them re-order :).
    2. About 2 screens later on that page, you get to a section that DOES describe how to re-order, but according to the API docs it's using a setter (.loaders) that doesn't exist. It seems the API docs are wrong, since we can assign to that variable?

    ...but it also seems to overwrite the data in the project, instead of only at runtime, which leaves me thinking "surely this isn't the way they intend us to control which headsets are being loaded? Runtime methods that change the project assets are a nightmare and this can't be right?"
     
  9. visionnaireMedia

    visionnaireMedia

    Joined:
    Jul 25, 2016
    Posts:
    17
    Hello everyone, I just started putting the CardBoard plugin in it.
    I don't need to have it running as the app runs so what I do is the code posted above:
    Code (CSharp):
    1.  public IEnumerator InitXR()
    2.     {
    3.         yield return  XRGeneralSettings.Instance.Manager.InitializeLoader();
    4.     }
    And I call that function in the
    Start()
    function of my main GameObject, and then, after at least 20s I actually run
     UnityEngine.XR.Management.XRGeneralSettings.Instance.Manager.StartSubsystems();
    , but as I run
    StartSubsystems()
    the apps crashes with no useful extra information.

    Am I doing something wrong?
     
  10. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    In the last week, I've @-mentioned two of the Unity team who've talked about this specifically, and had replies from neither :(. Plus the multiple times I've replied to them on the forums (going back ... a month? more?) requesting clear up-to-date docs on this specific topic.

    At this point you're best filing a new bug, waiting 4-6 weeks, and then you can discuss it with them when they read it (based on current wait times, that's about how long it takes for XR bugs to get looked at). Hopefully you'll get a reply before you need it for your live project.
     
    visionnaireMedia likes this.
  11. Saaskun

    Saaskun

    Joined:
    Nov 29, 2019
    Posts:
    51
    Same problem here, the problem is with the DeinitializeLoader() function :(
     
  12. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    None of those apis are intended to change runtime information since we can't guarantee that what you set is actually correct for the given build (Subsystems, settings, boot information). That API is not intended to be used at runtime as you are using it but the API currently doesn't stop you (a bug we need to correct on our end).
     
    a436t4ataf likes this.
  13. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What provider are you using and trying to Deinit? Are there any errors or anything in the Editor or Player logs?
     
  14. JabbaTheFat10

    JabbaTheFat10

    Joined:
    Aug 8, 2018
    Posts:
    2
    Same issue here with the DeInitializeLoader() function. The code below works when I call the function StartXR() and the function StopXR() but if I call again the StartXR() function, the app crash. I think the problem is the DeinitializeLoader() funtion.

    Code (CSharp):
    1.  
    2. IEnumerator StartXR()
    3. {
    4.     yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
    5.     if (XRGeneralSettings.Instance.Manager.activeLoader == null)
    6.     {
    7.         Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    8.     }
    9.     else
    10.     {
    11.         Debug.Log("Starting XR...");
    12.         XRGeneralSettings.Instance.Manager.StartSubsystems();
    13.         yield return null;
    14.     }
    15. }
    16.  
    17. void StopXR()
    18. {
    19.     if (XRGeneralSettings.Instance.Manager.isInitializationComplete)
    20.     {
    21.         XRGeneralSettings.Instance.Manager.StopSubsystems();
    22.         Camera.main.ResetAspect();
    23.         XRGeneralSettings.Instance.Manager.DeinitializeLoader();
    24.     }
    25. }
    Any help?
     
    joanpescador likes this.
  15. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    That should work as you have it. What provider are you using? I am wondering if this is a provider issue in that the provider may not be happy restarting like this for some reason.

    If the app crashes, do you have the player log to look at and see what is reported in there?
     
  16. JabbaTheFat10

    JabbaTheFat10

    Joined:
    Aug 8, 2018
    Posts:
    2
    Hi joejo,

    First of all, what do you mean by "provider"?

    Secondly, I used the Windows terminal command "adb logcat -s Unity" to debug the app but I cannot find error or exception.
    In the first one (Start1) the debug terminal show the code below:

    08-07 13:56:04.266 9073 9121 D Unity : [Subsystems] Loading plugin CardboardXrProvider for subsystem Display...
    08-07 13:56:04.270 9073 9121 D Unity : [Subsystems] Cardboard successfully registered Provider for Display
    08-07 13:56:04.270 9073 9121 I Unity : [XR] [CardboardXrMain]: Display subsystem successfully loaded.
    08-07 13:56:04.270 9073 9121 D Unity : [Subsystems] Cardboard successfully registered Provider for Input
    08-07 13:56:04.270 9073 9121 D Unity : [Subsystems] Cardboard successfully registered Provider for Display
    08-07 13:56:04.270 9073 9121 I Unity : [XR] [CardboardXrMain]: Input subsystem successfully loaded.
    08-07 13:56:04.272 9073 9121 D Unity : [Subsystems] Loading plugin CardboardXrProvider for subsystem Input...
    08-07 13:56:04.272 9073 9121 I Unity : [XR] [CardboardXrInputProvider]: Lifecycle initialized


    The second time I call the Initialization function (Start1 --> Stop1 -->Start2), the application flow ends with "[Subsystems] Loading plugin CardboardXrProvider for subsystem Display..." :

    08-07 13:56:10.440 9073 9121 D Unity : [Subsystems] Loading plugin CardboardXrProvider for subsystem Display...
    08-07 13:56:11.625 9073 9073 I Unity : onPause
    08-07 13:56:15.636 9073 9073 W Unity : Timeout while trying to pause the Unity Engine.
    08-07 13:56:15.670 9073 9073 I Unity : windowFocusChanged: false
    08-07 13:56:19.767 9073 9073 W Unity : Timeout while trying detaching primary window.
    08-07 13:56:19.775 9073 9073 I Unity : onDestroy


    Have you any idea to find a solution?
     
  17. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Looks like your are using Google's Cardboard provider. And it looks like they may have an issue on their end. We don;t support Cardboard as that is provided directly by Google so you will have to go to their forums/help to see if there is any info there on this.
     
    Saaskun likes this.
  18. Saaskun

    Saaskun

    Joined:
    Nov 29, 2019
    Posts:
    51
    Google's Cardboard sdk too.. I'll check their forums
     
  19. mfuad

    mfuad

    Unity Technologies

    Joined:
    Jun 12, 2018
    Posts:
    335
    Hi all, I raised the Google Cardboard issues with the Google team and they pointed out this is likely represented in Issue #38. They are aware of this issue, and recommend using github.com/googlevr/cardboard to report any future issues you have with the Cardboard plugin.
     
    joanpescador and Saaskun like this.
  20. DriesVrBase

    DriesVrBase

    Joined:
    Mar 24, 2020
    Posts:
    65

    I use this code. I use StartXR on the start of my player once he switches to a certain scene.
    But somehow eh doesn't do the 'yield return XRGeneralSettings.Instance.Manager.InitializeLoader();' correctly and i get the error " Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");"

    What can I do to fix this? I use this in another project and there it works fine.
     
  21. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Just like it says, check the player log to see if there are any errors and then you may be able to see what is going on.
     
  22. DriesVrBase

    DriesVrBase

    Joined:
    Mar 24, 2020
    Posts:
    65
    Ofcourse but there was nothing there.
    Seemed it was the steamvr that needed an update
     
  23. dwipayana24071995

    dwipayana24071995

    Joined:
    Mar 11, 2020
    Posts:
    1
    tnks , its work
     
  24. joanpescador

    joanpescador

    Joined:
    Dec 21, 2016
    Posts:
    122
    It works smoothly to me with Oculus Quest2. Thanks Jabba!
     
    dawnr23 likes this.