Search Unity

UWP twice XRSettings.enabled = true crash and exit game

Discussion in 'Windows Mixed Reality' started by IElectric, Dec 23, 2018.

  1. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I have a strange behavoir on my game after update from Unity 2018.2 to Unity 2018.3, this is my code :

    Code (CSharp):
    1. private void EnableVisor()
    2.     {
    3.         #if UNITY_WSA
    4.             this.StartCoroutine(this.LoadVisor("WindowsMR", true));
    5.         #else
    6.             this.StartCoroutine(this.LoadVisor("OpenVR", true));
    7.         #endif
    8.     }
    9.     private void DisableVisor()
    10.     {
    11.         //none
    12.         this.StartCoroutine(this.LoadVisor("", false));
    13.     }
    14.  
    15.     private IEnumerator LoadVisor(string StringVisor, bool BoolEnable)
    16.     {
    17.         UnityEngine.XR.XRSettings.LoadDeviceByName(StringVisor);
    18.  
    19.         yield return null;
    20.  
    21.         if(BoolEnable == true)
    22.         {        
    23.             //Abilitazione della modalità di gioco in realtà virtuale
    24.             UnityEngine.XR.XRSettings.enabled = true;
    25.  
    26.             UnityEngine.XR.InputTracking.disablePositionalTracking = true;
    27.  
    28.       if(UnityEngine.XR.XRDevice.isPresent == false)
    29.       {
    30.         UnityEngine.XR.XRSettings.LoadDeviceByName("");
    31.  
    32.         yield return null;
    33.  
    34.         UnityEngine.XR.XRSettings.enabled = false;
    35.       }
    36.  
    37.             //Impostazione della visuale della telecamera
    38.             this.Person1Object.GetComponent<PersonScript>().ViewHead();
    39.         }
    40.         else
    41.         {
    42.             //Disabilitazione della modalità di gioco in realtà virtuale
    43.             UnityEngine.XR.XRSettings.enabled = false;
    44.  
    45.             //Impostazione della visuale della telecamera
    46.             Camera.main.GetComponent<CameraScript>().enabled = false;
    47.  
    48.             Camera.main.transform.SetParent(null, false);
    49.  
    50.             Camera.main.rect = new Rect(0, 0, 1, 1);
    51.  
    52.             Camera.main.transform.position = new Vector3(0, 15, -5);
    53.             Camera.main.transform.rotation = Quaternion.identity;
    54.             Camera.main.transform.Rotate(90, 0, 0);                
    55.         }
    56.     }
    When I first call EnableVisor all works properly and the game start in WMR mode but if I call DisableVisor and then again EnableVisor the game window close and exit.

    This not happen in the Unity editor and in the prior version of Unity like 2018.2.7f1, in the old version of Unity prior 2018.3 I can enable and disable WMR whitout problem, I don't know where to start to find the issue because debugger doesn't show me any exceptions.

    I'm using :

    Unity 2018.3.0f2;
    Visual Studio 2017 Version 15.9.4

    I have observed that when I call UnityEngine.XR.XRSettings.enabled = true a second time the game exit.

    Thank you very much, Best regards...
     
    Last edited: Jan 8, 2019
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,627
    are there any messages in the player.log?
     
  3. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, thank you for your suggestion, I don't kow exactly where I can find player.log, in my AppData\LocalLow i can't find it, but I have execute the game in debug mode and when I try to enable a second time WMR mode I have found the following errors…

    i1.png
    seems something wrong on spatial input manager initialization, the configuration of my project is that

    i2.png

    I have try also with .NET 4.x Scripting backend but nothing, on my published game at

    https://www.microsoft.com/store/apps/9P5GJQXZL1BQ

    and made by Unity 2018.2.7f1 I have no problem to enable WMR more than one time, Best regards...
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    Maybe try loading the sdk "None" in the list, this might help instead of loading a blank string? This would end XR and the app would most likely go to a desktop app.
     
  5. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, thank you for your reply, I have tried to fit "None" istead of blank string but it doesn't work, the second time that I try to activate VR mode the game window close.

    This not happen in the Unity editor and in the old version of the game published on the store, I don't know what to do, please help, Best regards…

    1.png
     
    Last edited: Dec 28, 2018
  6. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    I think this is coming down to a misunderstanding in the code for the xrsettings.enabled. I believe that you are disabling all of XR by setting that API to false. When this happens you turn off the list and all of XR.

    If you want to disable to HMD, load "None" in the list, and then to re-nable the the HMD load the XR SDK you want to use.

    I think it comes down to be to aggressive on turning off the HMD
     
  7. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I have tried to not call xrsettings.enabled = false, and different combination of code, but nothing to do, I'm still on the same problem;

    In Unity editor when LoadDeviceByName("None") is called the Windows Mixed Reality portal come back to HOME, and the game can be re-enabled in VR mode;

    3.png

    In the Master Build of the game when LoadDeviceByName("WindowsMR") is called for the first time the game go in VR mode;

    4.png

    But when LoadDeviceByName("None") is called the Windows Mixed Reality portal go to black backgound;

    5.png

    The next time that the LoadDeviceByName("WindowsMR") is called the game crash and close;

    I'm sorry but at this time I'm very confused, I'm not too expert but I think that there is a bug in the generated code, the same code to enable/disable VR works properly in the old version of Unity, I'm sure on 2018.1.6f1 version, thank you a lot for your support, Cheers...
     
    Last edited: Dec 29, 2018
  8. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, same code on standalone build works perfect, OpenVR over Windows Mixed Reality can be enabled and disabled more than one time.

    I will very appreciate if someone can help me to solve the issue beacuse I'm stuck to update my game on Microsoft Store, the problem is the code that enabled a second time the Virtual Reality mode on UWP build.

    In the Unity editor the UWP works perfect but in the master build of the game the second time that I try to enable VR the game crash and exit, Thank you very much, Best regards...
     
  9. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Hey IElectric, sorry for the late-late reply. We were on holiday for the last bit of December.

    I'd love to have you file a new issue for us and we can take a look at a min-repro project if you reproduce this consistently. If you file a bug, post the issue number here so I can go nudge it along right away.
     
  10. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I have opened an issue, thanks in advance for your support, Cheers…

    r.png

    next I explain in more detail what happen...
     
  11. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    This is what happen in UWP master build version;

    this is the code;
    v.png

    when I enable the VR the first time the game works properly and the WMR portal show the HDM view;

    1.png

    when I disable the VR the first time the game still works but the WMR device portal is black;

    2.png

    the next time that I re-enable the VR mode the game freeze, crash, exit and the WMR portal is black until the game close;

    3.png

    I catch some errors in debug mode but I don't know if is the real cause of the crash;

    e.png

    On debug mode attached to CPP project the game crash after loading a second time the "WindowsMR" device at this line of code :

    UnityEngine.XR.XRSettings.enabled = true;

    continue...
     
    Last edited: Jan 8, 2019
  12. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    This is what happen in standalone build version (same code as UWP version);

    when I enable the VR the first time the game works properly and the WMR portal show the HDM view;

    4.png

    when I disable the VR the first time the game still works and the WMR device portal is active;

    5.png

    the next time that I re-enable the VR mode the game works properly;

    6.png

    each time I disable and enable the VR mode the game still works;

    continue...
     
  13. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    This is what happen in the Unity UWP editor (same code);

    when I enable the VR the first time the game works properly and the WMR portal show the HDM view;

    7.png

    when I disable the VR the first time the game still works and the WMR device portal show the cliff house;

    8.png

    the next time that I re-enable the VR mode the game works properly;

    9.png

    each time I disable and enable the VR mode the game still works;

    the build settings are

    12.png

    the player settings are

    10.png

    I'm using :

    Unity 2018.2.0f2
    Visual Studio 2017 Community

    Best regards...
     
    Last edited: Jan 8, 2019
  14. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Thanks for the info and I found your issue in our system! I will get this looked at soon as we can and if we need any additional details we may reach out in email from anyone in the QA team when we try to reproduce the issue.
     
  15. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I have tested on Unity 2019.1 but the issue is still present. Someone know a workaround to avoid the crash on UWP build of WMR when XRSettings.enabled = false and then = true ? The latest version of Unity where it's works was 2018.2.xx, thank you very much, Best regards...
     
  16. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, any chance to know when the issue will be fixed ? I'm stuck on publish an update on Microsoft Store because the game crash, I'd like to apply a workaround but I don't know where to start, thank you, Best Regards...
     
  17. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Hello IElectric, I went to double check your issue on my own project and could not reproduce it on the latest 2018.4 release. Would you be able to upgrade to 18.4 and checking if you still have the issue?
     
  18. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I have updated my project to Unity 2019.1.4, do you think that is possible to downgrade the project to 2018.4 ? Thank you a lot for your reply, Cheers...
     
    Last edited: Jun 19, 2019
  19. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    We do not officially support downgrading of a project. Not to say it can't be done, but it's not something we support. Your mileage may vary if you attempt to do it.
     
  20. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, do you know if on Unity 2019.2.2f1 the issue is fixed ? I have tested it but seems doesn't work, thank you, Cheers…

    fix.png
    issue.png
     
    Last edited: Aug 24, 2019
  21. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    @IElectric can you file a new bug for us please, I just double-checked 19.2.2f1 and am not crashing when toggling XR Settings. Make sure to include a minimum repro project attached with whatever script you're using to toggle it off and back on again.
     
  22. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hi, I'm using Unity 2019.2.2f1 and Visual Studio Community 2017 15.9.4, I hope that the next image is useful, in any case where can I download your test project ? Thank you very much, Cheers…

    This exception happen when I toggle XR from ON to OFF and then ON again
    debug.png

    I belive that is the same issue…
    xr.png
     
    Last edited: Aug 27, 2019
  23. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    I was using the test project attached to 1155138. File a new bug for me under Help > Report a Bug and I'll take a look at your repro project. Perhaps you have the magic touch that still reproduces the crash.
     
  24. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Sorry, please give me the link to download the test project 1155138, I can't find it, thank you, Cheers...
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,814
    Unfortunately we cannot share projects reported through our bug reporter. That goes against keeping them confidential (even if you reported the bug originally).
     
  26. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    557
    Hello,

    Please make sure to have built a min repro project (a small project that has only what is required to reproduce the bug) that we can use to produce the bugs. Then please follow these steps.

    Steps:
    1.) Open the current unity editor you are using
    2.) Build a min repro project
    3.) Click the Help tab
    4.) Click Troubleshoot Issue...
    5.) Then in the bottom right of the menu that pops click Report a new Issue.

    Without these steps there is not really anymore support we can provide without being able to reproduce the issue on our side.

    Thank you,
    Wesley
     
  27. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I know that is better to open an issue tracker but at this time I'm stuck on the test project. I have build a test project on windows mixed reality, you can download it at

    the project works properly on standalone OpenVR over Windows Mixed Reality
    win.png

    works also properly in the Unity editor as UWP Windows Mixed Reality
    editor.png

    but doesn't work on Windows Mixed Reality UWP build
    wmr.png
    er.png

    Thanks in advance if you can test the project and explain me what is wrong, Cheers...

    I'm using Unity 2019.2.2f1 and Visual Studio 2017 Community 15.9.14
     
    Last edited: Oct 4, 2019
  28. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, I've understand why my test project doesn't work. On my notebook there are two graphics adapter, one integrated and an high performance GPU, by default nvidia settings select low performance GPU and the test project doesn't work.

    Now the test project works because I have forced the graphics adapter to works on high performance GPU, now I can open another issue tracker because I don't understand why my game crash when Windows Mixed Reality is switched ON, then OFF, then ON again, Best Regards…

    High performance GPU settings
    nvid.png

    The test project crash when VR is switched ON again
    boo.png
     
  29. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Issue opened, Cheers…

    iss.png
     
    JasonCostanza likes this.
  30. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Thank you IElectric, we will take a look at that as soon as we can
     
  31. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, sadly I need to signal that on the latest version of Unity 2019.2.13f1 my game still has the same problem on WMR mode.

    I have build my game as UWP, I'm using Visual Studio 2017 Community and the situation is that :

    In Unity Editor as universal Windows Platform the game works properly, Windows Mixed Reality can be enabled and disabled always and the game doesn't crash;

    Standalone Build as x64 .NET WMR over SteamVR works properly, XR can be enabled and disabled always and the game doesn't crash;

    UWP Build as Master crash when the Windows Mixed Reality is enabled a second time;

    player.png
    build.png
    w10.png

    Seems that the issue is fixed, problably it's my computer, my operating system or my HDM visor but I would like to understand why last year with the Unity 2018.2.xx the same game and code works properly with WMR enable/disable.

    issue.png

    This is the error that Visual Studio show in debug mode :

    VRerror.png

    I'm waiting Unity 2019.3 but until this version I'd like to know if someone else have the same problem, thank you very much, Best Regards...
     
    JasonCostanza likes this.
  32. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Hello, if you're reproducing this in a new editor version, let's have you file a new bug and we'll treat it in a brand new light. There's been a lot of change since we tackled this last time so things might be quite different than before. Can you file a bug and post the number here please?
     
  33. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    Hello, can I ask you to send me a mini project example that I can test on my system ? If the project works on Unity system the issue is my project. I hope is possible to give me a link to download the example project on a private message, thank you very much for your support, Cheers...
     
  34. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    349
    Unfortunately we are not authorized to provide project files. We will need a bug report from your project or a new minimum repro project you create and we can use that to diagnose the issue you're seeing or advise a change in your project to resolve it.
     
  35. IElectric

    IElectric

    Joined:
    May 31, 2016
    Posts:
    131
    OK, thank you anyway, I will wait for Unity 2019.3, I develop videogames for hobby, is not a problem for me, Cheers...
     
    Last edited: Nov 26, 2019