LocalJoost / QRCodeService

Show a MRTK2 service to read (and position) QR codes using HoloLens 2
MIT License
76 stars 25 forks source link

Unity crashes when using Holographic Remoting to a Hololens 2 with Microsoft.MixedReality.QR #11

Closed TinusHeystek closed 1 year ago

TinusHeystek commented 2 years ago

Hello Joost

Just as an update on a issue I had with the "Microsoft.MixedReality.QR" code. When running Unity Holographic Remoting on Play Mode, Unity became unresponsive/hanging and then crashed. I assumed that it was something weird in Unity and so opened a support ticket.

After amazing support from unity it was pointed out that there was an infinite loop in then "QRCodeService" source.

Response from Unity Support.

We've been able to find the cause of this crash. When exiting Playmode and MonoBehavior.OnDisable() triggered, Time.time will be reset to 0. 
In the QRTrackerController.cs script on line 33, this reset is causing an infinite loop as the following will always be true:
while (!MixedRealityToolkit.IsInitialized && Time.time < 5);
therefore causing the Editor to hang.

If you change the logic of the while statement to avoid triggering this infinite loop such as adding a condition like Time.time > 0 then the editor will not hang. Please let me know if this fixes the issue for you. 

Best regards

After applying the recommendation the issue was resolved for me. If possible could you please update accordingly.

Kind Regards.

LocalJoost commented 2 years ago

This is very odd. I never have had this problem. The idea of this loop was that it waits for the MRTK to be initialized for a maximum of 5 seconds. I am not quite sure what you are doing different from me

adconk commented 1 year ago

Hi @LocalJoost, @torynfarr and I have encountered this issue as well. When we go to Exit Unity Playmode, it hangs because of this service.

LocalJoost commented 1 year ago

@adconk I am a BT surprised as I never had this problem myself. What Unity version are you using and what did you change?

torynfarr commented 1 year ago

@LocalJoost Our project is using Unity 2022.2.5f1. It's been about a month since I implemented the QR code tracking in our project, but I think the only real change was that we made was to replace the SpatialGraphCoordinateSetter script with the open XR version from your other branch. I think in my initial testing, the issue was occurring even if I just loaded your base project in Unity 2022.2.5f1.

It doesn't happen on device. Everything works fine in an actual build. I think the issue is specific to using Holographic remoting when running in the editor.