-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Describe the bug
As title describes, we are getting exception when we stop play mode in Unity editor while spatial meshing is turned on. See full exception log from Unity below:
MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object.set_name (System.String value) (at <a1ac446df41c4a67becf2f8317dc1792>:0)
Microsoft.MixedReality.Toolkit.XRSDK.GenericXRSDKSpatialMeshObserver.ReclaimMeshObject (Microsoft.MixedReality.Toolkit.SpatialAwareness.SpatialAwarenessMeshObject availableMeshObject) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Providers/XRSDK/GenericXRSDKSpatialMeshObserver.cs:441)
Microsoft.MixedReality.Toolkit.XRSDK.GenericXRSDKSpatialMeshObserver.RemoveMeshObject (System.Int32 id) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Providers/XRSDK/GenericXRSDKSpatialMeshObserver.cs:417)
Microsoft.MixedReality.Toolkit.XRSDK.GenericXRSDKSpatialMeshObserver.ClearObservations () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Providers/XRSDK/GenericXRSDKSpatialMeshObserver.cs:299)
Microsoft.MixedReality.Toolkit.SpatialAwareness.BaseSpatialObserver.CleanupObservationsAndObserver () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Providers/BaseSpatialObserver.cs:219)
Microsoft.MixedReality.Toolkit.SpatialAwareness.BaseSpatialObserver.Destroy () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Providers/BaseSpatialObserver.cs:120)
Microsoft.MixedReality.Toolkit.BaseDataProviderAccessCoreSystem.UnregisterDataProvider[T] (T dataProviderInstance) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Services/BaseDataProviderAccessCoreSystem.cs:332)
Microsoft.MixedReality.Toolkit.SpatialAwareness.MixedRealitySpatialAwarenessSystem.Disable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Services/SpatialAwarenessSystem/MixedRealitySpatialAwarenessSystem.cs:108)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit+<>c.<DisableAllServices>b__75_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService service) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Services/MixedRealityToolkit.cs:1079)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesReverseOrder (System.Action`1[T] execute) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Services/MixedRealityToolkit.cs:1168)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.DisableAllServices () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Services/MixedRealityToolkit.cs:1079)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.OnDisable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@208cd71b0c2e-1652706595505/Core/Services/MixedRealityToolkit.cs:750)
To reproduce
Steps to reproduce the behavior:
- Create an MRTK app in Unity for Hololens 2 with spatial awareness enabled by following the MRTK project setup instructions here.
- Switch to UWP build platform, then build and run the app on Hololens 2.
- See that spatial awareness and the spatial mesh are running properly
- Stop the play mode in Unity editor while Hololens is detecting spatial meshes.
Note that this bug is not triggered every time, so that it might require to follow the steps couple of times. Also following settings of MRTK helps to observe the bug easier:
- Set spatial mesh update interval around 1 second
- Set level of detail of spatial mesh to 'Fine'
Expected behavior
I would expect that I would be able to stop play mode in Unity without having exceptions.
Screenshots
Your setup (please complete the following information)
- Unity Version 2019.4.21f
- MRTK Version 2.7.3
Target platform (please complete the following information)
- HoloLens 2
