Search Unity

Resolved Windows build runtime log hang "[XR] Error determining if we should quit: Not Initialized"

Discussion in 'VR' started by AVOlight, Oct 19, 2020.

  1. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    app with XR mode optional
    Unity 2020.9.1f1
    "com.unity.xr.management": "3.2.16"
    Windows Build
    il2cpp
     
  2. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    What XR provider are you targeting?
     
  3. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    i target these 3 with one build
    "com.unity.xr.oculus": "1.5.0",
    "com.unity.xr.windowsmr": "4.0.2",
    "com.valvesoftware.unity.openvr": "1.0.1",

    it might be happening because i have this set m_InitManagerOnStart: 1
    and launching with -vrmode none
    is a workaround that returns false here
    private bool CheckGraphicsAPICompatibility(XRLoader loader)
    for all loaders

    this was working without the log hang so might just roll back "com.unity.xr.management"
     
  4. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Is this a build time or runtime error you are seeing? What happens if you disable the different providers? I'm pretty sure that error doesn't come from management or WMR so wondering if Oculus or OpenVR are throwing int.
     
  5. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    runtime of build with "-vrmode none" launch params
    which means none of the 3 loaders have been init
    Initialize() is only allowed if CheckGraphicsAPICompatibility returns true for that loader
    "com.unity.xr.management" -> XRManagerSettings.cs -> CheckGraphicsAPICompatibility
     
  6. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    That command line flag (-vrmode) was for legacy XR and does not do anything for XR SDK based applications.
     
  7. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    i added support

    Code (CSharp):
    1. // add this method
    2.         public bool app_launch_args_contain(string value)
    3.         {
    4.             var args = System.Environment.GetCommandLineArgs();
    5.             for (int i = 0; i < args.Length; i++)
    6.             {
    7.                 if (args[i].IndexOf(value, System.StringComparison.OrdinalIgnoreCase) >= 0)
    8.                     return true;
    9.             }
    10.             return false;
    11.         }
    12.         // above this existing method
    13.         private bool CheckGraphicsAPICompatibility(XRLoader loader)
    14.         {
    15.             // add this
    16.             if (app_launch_args_contain("-vrmode"))
    17.             {
    18.                 if (app_launch_args_contain("none")) { return false; }
    19.                 else if (app_launch_args_contain("openvr"))
    20.                 {
    21.                     if (loader == loaders[0]) { return false; } // OpenVR is 2nd
    22.                 }
    23.                 else if (app_launch_args_contain("windowsmr"))
    24.                 {
    25.                     if (loader == loaders[0]) { return false; }
    26.                     if (loader == loaders[1]) { return false; } // WindowsMR is 3rd
    27.                 }
    28.             }
    29.             // before existing method contents
    30.             GraphicsDeviceType deviceType = SystemInfo.graphicsDeviceType;
    31.             List<GraphicsDeviceType> supportedDeviceTypes = loader.GetSupportedGraphicsDeviceTypes(false);
    32.  
    33.             // To help with backward compatibility, if the compatibility list is empty we assume that it does not implement the GetSupportedGraphicsDeviceTypes method
    34.             // Therefore we revert to the previous behavior of building or starting the loader regardless of gfx api settings.
    35.             if (supportedDeviceTypes.Count > 0 && !supportedDeviceTypes.Contains(deviceType))
    36.             {
    37.                 Debug.LogWarning(String.Format("The {0} does not support the initialized graphics device, {1}. Please change the preffered Graphics API in PlayerSettings. Attempting to start the next XR loader.", loader.name, deviceType.ToString()));
    38.                 return false;
    39.             }
    40.  
    41.             return true;
    42.         }
     
  8. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    I'm not sure why you are doing this? What is it that you are even trying to achieve with these changes? Why not just disable InitMangerOnStart and manually start the system?
     
  9. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    could only get builds to work consistently with InitMangerOnStart set to true; toggling XR mode would also cause issues
    so this is my workaround
    also when i added support there wasn't any other way to choose which loader to load
    has this changed?
     
  10. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    Did you use the XR Plug-in management UI? Not sure what you mean by "choose which loader to load"?
     
  11. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    thank you for your help
    by adding that code i can use the same build to launch any vr mode
    "-vrmode none" "-vrmode openvr" etc.
    choosing any of the loaders to init first

    how can i do that without my edits?
     
  12. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    I do not recommend (and Unity does not support) hacking the management script direclty.

    For in editor, you can change the Loader List at any time using script. You can also do that in a build script when you generate player builds. The loader list on XRGeneralSettings is modifiable, and there are many threads in this forum with people doing just that. Shouldn't be too hard to find one if you search around.

    Runtime support for this is not available at this time. If this is what you want to do at runtime then you might as well disable the InitManagerAtStart and manually control the loader you wish to use yourself.
     
  13. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    thank you; runtime is easiest for me;
    for anyone else having this issue:
    "com.unity.xr.oculus": "1.5.0" ...
    from the new OculusPlayerLoop file
     
    Last edited: Oct 22, 2020
  14. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    We are now seeing the same
    [XR] Error determining if we should quit: Not Initialized

    on our server build ... this wasn't an issue till this build
    what causes this message to print we cant find it by simply searching
     
  15. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    @lodendsg the cause is this line
    Code (CSharp):
    1. if (NativeMethods.GetAppShouldQuit())
    inside
    Library\PackageCache\com.unity.xr.oculus@1.5.0\Runtime\OculusPlayerLoop.cs
    Package Manager -> Oculus XR Plugin

    they use this hook
    Code (CSharp):
    1. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    instead of hooking inside the override Initialize() method of there XR loader file...

    the easiest workaround is downgrading to
    "com.unity.xr.oculus": "1.4.3"
    which can be done editing the version number in
    Packages\manifest.json
    if the option isn't available here
    Package Manager -> Oculus XR Plugin
     
  16. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480

    Thank you for the responce we determined it to be a bug on Unity's part our selves where in the Oculus XR Framwork plugiin is now a problem. It wasn't in the previous version.

    So for now we have removed Oculus plugin support in hopes they will patch it up before we need it. Our app supports non-VR as well as multiple VR platforms so we can work around Oculus not being supported for a bit
     
  17. AVOlight

    AVOlight

    Joined:
    Apr 15, 2014
    Posts:
    427
    yea mine too and I prefer to have 1 build that does it all with launch params
    reported it to Oculus on 23rd here (https://developer.oculus.com/bugs/)
    no response yet
     
  18. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    Ya saw I think a couple of people pointing it out. In our case the user can go in and out of VR during a session so launch params wont work for us rather we have to test at run time is the user going in or out of a VR experance and we do the nessisary work to spin up or shut down the XR presentation subsystems.

    Granted with Oculus since its standalone it will always start and stay in Oculus assuming its not being used with PC ... Oculus honistly is an odd one with that. I do wish Unity had a bit better support for the concept of going in and out of VR. Our own experance is that VR while cool and all is also tiering and its nice to be able to pop into and out of VR in game play without needing to shut down and reload. Our approch does work with the XR Framework they have but it feels really hackish to do simple things like detect if we are currently in VR, is a VR device available and ready to use, and to shut down VR when the user wants.
     
  19. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    So I still see this issue in Unity 2019.4.20
    The log is just full of the message when we have not tried to go into VR (user can enter or exit as want)

    Edit: However I think it may have been fixed in 1.6 or 1.7 as updating the plugin seems to stop it
     
    Last edited: Mar 3, 2021
  20. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    105