microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Crash when disabling spatialmappingmanager's visual meshes #62

Closed flarb closed 8 years ago

flarb commented 8 years ago

In my project, setting DrawVisualMeshes to false gives me an exception. In this case, I'm triggering it from a voice command where I stop the observer and stop the drawing of the meshes like so:

_spatialMM.StopObserver(); _spatialMM.DrawVisualMeshes = false;

And I get this exception:

Exception thrown: 'System.NullReferenceException' in WinRTBridge.winmd NullReferenceException: Exception of type 'System.NullReferenceException' was thrown. at WinRTBridge.Utils.ThrowNewNullReferenceException(String message) at UnityEngineProxy.InternalCalls.PInvokeCalls.Renderer_Set_Custom_PropEnabled(IntPtr param_0, Boolean param_1) at UnityEngineProxy.InternalCalls.Renderer_Set_Custom_PropEnabled(Object self, Boolean paramValue) at HoloToolkit.Unity.SpatialMappingManager.UpdateRendering(Boolean Enable) at GameManager.ToggleObserver(Boolean on) at GameManager.StartPlacement() at GUIManager.OnPlayCommnand() at UnityEngine.Events.InvokableCall.Invoke(Object[] args) at UnityEngine.Events.InvokableCallList.Invoke(Object[] parameters) at HoloToolkit.Unity.KeywordManager.KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args) at UnityEngine.Windows.Speech.PhraseRecognizer.InvokePhraseRecognizedEvent(String text, ConfidenceLevel confidence, SemanticMeaning[] semanticMeanings, Int64 phraseStartFileTime, Int64 phraseDurationTicks) at UnityEngine.Windows.Speech.PhraseRecognizer.$Invoke6(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: Line: 0)

The program '[4280] HoloToolkit-Unity.exe' has exited with code -1 (0xffffffff).

flarb commented 8 years ago

Also just stopping the observer (commenting out the second line) gives me a similar exception, just somewhere with no callstack.

DanHolbert commented 8 years ago

Hi Ralph,

It seems like one of the MeshRenderer components (Source.GetMeshRenderers()) is somehow invalid at this point. I’d put a breakpoint in UpdateRendering and inspect the renderers list.

In which of the following situations does this crash occur? in Unity, in the emulator, running the universal app on your desktop, or on a HoloLens device?

Cheers, Dan H

From: Ralph Barbagallo [mailto:notifications@github.com] Sent: Thursday, June 16, 2016 10:38 PM To: Microsoft/HoloToolkit-Unity HoloToolkit-Unity@noreply.github.com Subject: [Microsoft/HoloToolkit-Unity] Crash when disabling spatialmappingmanager's visual meshes (#62)

In my project, setting DrawVisualMeshes to false gives me an exception. In this case, I'm triggering it from a voice command where I stop the observer and stop the drawing of the meshes like so:

_spatialMM.StopObserver(); _spatialMM.DrawVisualMeshes = false;

And I get this exception:

Exception thrown: 'System.NullReferenceException' in WinRTBridge.winmd NullReferenceException: Exception of type 'System.NullReferenceException' was thrown. at WinRTBridge.Utils.ThrowNewNullReferenceException(String message) at UnityEngineProxy.InternalCalls.PInvokeCalls.Renderer_Set_Custom_PropEnabled(IntPtr param_0, Boolean param_1) at UnityEngineProxy.InternalCalls.Renderer_Set_Custom_PropEnabled(Object self, Boolean paramValue) at HoloToolkit.Unity.SpatialMappingManager.UpdateRendering(Boolean Enable) at GameManager.ToggleObserver(Boolean on) at GameManager.StartPlacement() at GUIManager.OnPlayCommnand() at UnityEngine.Events.InvokableCall.Invoke(Object[] args) at UnityEngine.Events.InvokableCallList.Invoke(Object[] parameters) at HoloToolkit.Unity.KeywordManager.KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args) at UnityEngine.Windows.Speech.PhraseRecognizer.InvokePhraseRecognizedEvent(String text, ConfidenceLevel confidence, SemanticMeaning[] semanticMeanings, Int64 phraseStartFileTime, Int64 phraseDurationTicks) at UnityEngine.Windows.Speech.PhraseRecognizer.$Invoke6(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: Line: 0)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/HoloToolkit-Unity/issues/62, or mute the threadhttps://github.com/notifications/unsubscribe/AQ8k1cfJ7GIc_tOOk9oTbSM70Ommyp3Eks5qMjKkgaJpZM4I4C8J.

flarb commented 8 years ago

This happens on device, I haven't been able to test it in the editor for a variety of reasons (we really need a system wide gesture input keyboard shortcut override as an editor script)--I'll give it a shot in the emulator, though.

angelaHillier commented 8 years ago

Thanks for reporting this issue! Pat just checked-in a fix for this: https://github.com/Microsoft/HoloToolkit-Unity/commit/e5fa08a833c6b20bf220297244a1d2b9f0949307