chgatla-microsoft / QRTracking

MRTK sample app for QRtracking
MIT License
74 stars 69 forks source link

Unity Crashes when using Hololens Remote + Microsoft.QR #46

Open SamedAga opened 2 years ago

SamedAga commented 2 years ago

Hi there,

I found out, that Unity crashes randomly, whenever I use Hololens Remote + QR Tracking. It happens most of the time, when pressing either play or stopping play mode.

I believe, this is an issue related with Microsoft.QR. See my error log for reference.

Begin MonoManager ReloadAssembly
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.wrapper_native_00007FF90447A050 (intptr) [0x00009] in <695d1cc93cca45069c528c15c9fdd749>:0
  at WinRT.ObjectReference`1<Microsoft.MixedReality.QR.IQRCode/Vftbl>.Finalize () [0x00020] in <b26253d0c9e54efdbf5e403c47729e29>:0
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00020] in <695d1cc93cca45069c528c15c9fdd749>:0

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

System is: Windows 10 Hololens 2 Unity 2020.3.25f1 Microsoft.MixedReality.QR ver. 0.5.3013 Microsoft.VCRTForwarders.140 ver. 1.0.7 MRTK ver. 2.7.3.0

I updated to OpenXR and use the SpatialGraphNodeTracker script from here. I have a friend with the same issue.

maybe it is also related with this #6.

edit 1: I am not 100% sure, if hololens remote in combination with Microsoft.MixedReality.QR is the issue. building and running the app on the hololens 2 seems to work, but makes testing reallly hard for.

SebKranz commented 2 years ago

I run into the same random crashes after migrating to Unity 2020.3.25f1 and OpenXR with Remoting.

========== OUTPUTTING STACK TRACE ==================

0x000001F30D4E29F8 (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_00007FFB48F69550 (intptr)
0x000001F31F773DD9 (Mono JIT Code) WinRT.ObjectReference`1<Microsoft.MixedReality.QR.IQRCode/Vftbl>:Finalize ()
0x000001F30D3C7908 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFB43F6F1E0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2849] mono_jit_runtime_invoke 
0x00007FFB43EF2AC2 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke 
0x00007FFB43F54E56 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\gc.c:347] mono_gc_run_finalize 
0x00007FFB43F53B4E (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\gc.c:842] finalize_domain_objects 
0x00007FFB43F53DB5 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\gc.c:938] finalizer_thread 
0x00007FFB43F16BE8 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\threads.c:1068] start_wrapper_internal 
0x00007FFB43F16976 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\threads.c:1127] start_wrapper 
0x00007FFB85AF7034 (KERNEL32) BaseThreadInitThunk
0x00007FFB85DE2651 (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Windows 10 HoloLens 2 Unity 2020.3.25f1 Microsoft.MixedReality.QR 0.5.3013 MRTK: 7.3.0

SamedAga commented 2 years ago

Here an update:

@SebKranz : Do you have a working setup (e.g. via MRTK instead of OpenXR or another Unity version)?

I've also contacted Unity about this error and they say it is related to Microsoft.MixedReality.QR. Then contacted Microsoft, no answer yet.

I will update when I find a solution/workaround.

thomaswester commented 2 years ago

I can reproduce a Unity Editor crash on the second time I hit play.

Unity 2021.2.14f1 OpenXR 1.3 MRTK 2.7.3 Holographic Removing 2.7.4.0 Microsoft.MixedReality.QR.0.5.3013 via NuGet

I saw intermittent crashes in Unity 2020.3.18, it's reliably crashing in 2021.2.14

Commenting out QRCodeWatcher.RequestAccessAsync(); will make it all work, but then you won't get QR Code tracking Holographic Remoting.

I wonder if handle is not getting cleared when exiting playmode.

craig-ar-james commented 1 year ago

I can reproduce a crash with the unmodified QRTracking example (tried the yl/open-xr branch as I saw there was a commit 7 days ago to update to latest libraries).

I get a Unity crash using the Holographic Remoting every time I stop the debug session from Unity

Happens with Unity 2020.3.38f1 or 2020.3.37f1 MR OpenXR Plugin 1.5.0 MR Toolkit Foundation 2.8.2 MR Toolkit Standard Assets 2.8.2 Holographic Remoting Tool 2.8.1 (notable it doesn't match the MRTK but then this site suggests 2.8.1 is the latest: https://www.nuget.org/packages/Microsoft.Holographic.Remoting) Microsoft.MixedReality.QR 0.5.2112 (came with the demo) and also updated to v0.5.3019 with same result

HL2 windows 20348.1513

I'm running Windows 10 Version 21H2 (build 19044.1889)

Editor log attached after a simple open project, run in remoting tool, exit, crash cycle. I can't see anything obvious in the editor log

Crash happens whether I'm on wifi or USB-cabled to Hololens Crash goes away if I disable the new QRCodeWatcher in SetupQRTracking (ie been through the QRCodeWatcher.RequestAccessAsync() already)

Editor.log

[Update:] ... digging further in, it appears that once a call to SpatialGraphNode.FromStaticNodeId is called, shutdown in remoting will go on to crash Unity. This call uses a native library function so I surmise that there is some resourcing allocated that doesn't get cleaned up properly on shutdown. I have no further insight into the code from that point. I may be missing it, but there doesn't appear to be a way in the API to release this resource. This happens with FromStaticNodeId or From DynamicNodeId

CortexCore commented 1 year ago

So far, is there any way to solution? Yes,the reason of crash is called SpatialGraphNode.From(any)NodeId. guys have any way to solution it or get qr positon not by spatialGraphNode?

craig-ar-james commented 1 year ago

I'm just wrapping the call in... if (Application.platform != RuntimePlatform.WindowsEditor) { InitializeSpatialGraphNode(); } ... and only letting it get called at runtime - passing back pos/rot from a substitue object in the scene when running under the editor so I can move it around and test downstream code before shipping to HL for final testing.

EudenDev commented 1 year ago

Any update on this issue? We would like to test QR tracking from the Editor and indeed it happens after calling FromStaticNodeId or From DynamicNodeId.

Does MRTK3 have the same problem? Or is there any previous package version that doesn't crash on exit?

SitronX commented 1 year ago

If anyone is still having this issue, upgrading Mixed Reality OpenXR Plugin to 1.7.0 fixed it. It is Mixed Reality OpenXR plugin, not OpenXR Plugin that needs updating. It can be easily upgraded thru Mixed Reality Feature Tool where it is under Platform Support/Mixed Reality OpenXR Plugin

Ethan-Zhu-code commented 1 year ago

If anyone is still having this issue, upgrading Mixed Reality OpenXR Plugin to 1.7.0 fixed it. It is Mixed Reality OpenXR plugin, not OpenXR Plugin that needs updating. It can be easily upgraded thru Mixed Reality Feature Tool where it is under Platform Support/Mixed Reality OpenXR Plugin

Thank you! By the Way, still having the Issue using Mixed Reality OpenXR Plugin 1.7.0 with MRTK 2.8.2 in Unity 2020.3.43, problem fixed after upgrading MRTK to 2.8.3.

wbueschel commented 1 year ago

I still have the same issue with version 1.7.2 of the plugin and MRTK 2.8.3, unfortunately.

kikichristaki commented 1 year ago

I still have the same issue with version 1.7.2 of the plugin and MRTK 2.8.3, unfortunately.

Same issue for me with these versions.

madhuavunuri commented 10 months ago

I am still having the same issue. is any one able to fix it ?

pixelblue commented 9 months ago

I am on MRTK 2.8.3 with Mixed Reality OpenXR plugin 1.9.0 in Unity 2021.3.3LTS. It's more stable but it happens here and there after a couple of "Play" sessions using Remoting.

990863 commented 9 months ago

In my environment, calling QRCodesManager.StopQRTracking() solved the problem.

// QRCodesManager .cs

    public class QRCodesManager : Singleton<QRCodesManager>
    {
        ...

        private void OnApplicationQuit()
        {
            StopQRTracking();
        }
     }