Azure / azure-spatial-anchors-samples

Azure Spatial Anchors sample code
Other
293 stars 139 forks source link

CreateAnchor NullReferenceException #319

Closed rishabhaggarwal2 closed 2 years ago

rishabhaggarwal2 commented 2 years ago

I am trying to create an anchor using ASA for Hololens. First of all dll fails to attach in the editor. Then, when I build the application on the hololens, the session starts successfully and gives the percentage of room captured altough the SessionUpdated doesn't work.

Then, when trying to attach the anchor as follows:

  public async void CreateAnchor()
     {
         var localAnchor = GameObject.Instantiate(this.SpherePrefab, this.PlacementDisc.transform.position,
             this.PlacementDisc.transform.rotation);
         localAnchor.AddComponent<CloudNativeAnchor>();
         StatusText.GetComponent<TextMeshPro>().text = "anchored";
         CloudNativeAnchor cloudNativeAnchor = localAnchor.GetComponent<CloudNativeAnchor>();
         StatusText.GetComponent<TextMeshPro>().text = cloudNativeAnchor.isActiveAndEnabled ? "yayy" : "noo";
         if (cloudNativeAnchor.CloudAnchor == null)
         {
             StatusText.GetComponent<TextMeshPro>().text = "anchor was null";
             await cloudNativeAnchor.NativeToCloud();
             StatusText.GetComponent<TextMeshPro>().text = "received native to cloud";
         }  
         CloudSpatialAnchor cloudAnchor = cloudNativeAnchor.CloudAnchor;
         //cloudAnchor.AppProperties[@"model-type"] = @"frame";
         cloudAnchor.AppProperties[@"label"] = @"testing123";
         await this.cloudSession.CreateAnchorAsync(cloudAnchor);
         StatusText.GetComponent<TextMeshPro>().text = "created cloud anchor " + cloudAnchor.Identifier;
         localAnchor.GetComponent<Material>().color = Color.green;
     }

I get the following error:

 NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.AnchorHelpers.CreateAnchor (UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.AnchorHelpers.CreateWorldAnchor (UnityEngine.Transform transform) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent.Awake () [0x00000] in <00000000000000000000000000000000>:0 
   at UnityEngine.GameObject.AddComponent (System.Type componentType) [0x00000] in <00000000000000000000000000000000>:0 
   at UnityEngine.GameObject.AddComponent[T] () [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.CreateNativeAnchor (UnityEngine.GameObject gameObject) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.FindOrCreateNativeAnchor (UnityEngine.GameObject gameObject) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud (System.Boolean useExisting) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud () [0x00000] in <00000000000000000000000000000000>:0 
   at AnchorStoreManager+<CreateAnchor>d__10.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
   at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
   at AnchorStoreManager.CreateAnchor () [0x00000] in <00000000000000000000000000000000>:0 
   at UnityEngine.Events.InvokableCall.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
   at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Input.SpeechInputHandler.Microsoft.MixedReality.Toolkit.Input.IMixedRealitySpeechHandler.OnSpeechKeywordRecognized (Microsoft.MixedReality.Toolkit.Input.SpeechEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem+<>c.<.cctor>b__244_38 (Microsoft.MixedReality.Toolkit.Input.IMixedRealitySpeechHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.BaseEventSystem.HandleEvent[T] (UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] eventHandler) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.DispatchEventToGlobalListeners[T] (Microsoft.MixedReality.Toolkit.Input.BaseInputEventData baseInputEventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] eventHandler) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.HandleEvent[T] (UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] eventHandler) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.RaiseSpeechCommandRecognized (Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSource source, Microsoft.MixedReality.Toolkit.Utilities.RecognitionConfidenceLevel confidence, System.TimeSpan phraseDuration, System.DateTime phraseStartTime, Microsoft.MixedReality.Toolkit.Input.SpeechCommands command) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Windows.Input.WindowsSpeechInputProvider.OnPhraseRecognized (UnityEngine.Windows.Speech.ConfidenceLevel confidence, System.TimeSpan phraseDuration, System.DateTime phraseStartTime, System.String text) [0x00000] in <00000000000000000000000000000000>:0 
   at Microsoft.MixedReality.Toolkit.Windows.Input.WindowsSpeechInputProvider.KeywordRecognizer_OnPhraseRecognized (UnityEngine.Windows.Speech.PhraseRecognizedEventArgs args) [0x00000] in <00000000000000000000000000000000>:0 
   at UnityEngine.Windows.Speech.PhraseRecognizer.InvokePhraseRecognizedEvent (System.String text, UnityEngine.Windows.Speech.ConfidenceLevel confidence, UnityEngine.Windows.Speech.SemanticMeaning[] semanticMeanings, System.Int64 phraseStartFileTime, System.Int64 phraseDurationTicks) [0x00000] in <00000000000000000000000000000000>:0 
 UnityEngine.GameObject:AddComponent(Type)
 UnityEngine.GameObject:AddComponent()
 Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions:CreateNativeAnchor(GameObject)
 Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions:FindOrCreateNativeAnchor(GameObject)
 Microsoft.Azure.SpatialAnchors.Unity.<NativeToCloud>d__4:MoveNext()
 System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start(<NativeToCloud>d__4&)
 Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor:NativeToCloud(Boolean)
 Microsoft.Azure.SpatialAnchors.Unity.<NativeToCloud>d__5:MoveNext()
 System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start(<NativeToCloud>d__5&)
 Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor:NativeToCloud()
 <CreateAnchor>d__10:MoveNext()
 System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(<CreateAnchor>d__10&)
 AnchorStoreManager:CreateAnchor()
 UnityEngine.Events.InvokableCall:Invoke()
 UnityEngine.Events.UnityEvent:Invoke()
 Microsoft.MixedReality.Toolkit.Input.SpeechInputHandler:Microsoft.MixedReality.Toolkit.Input.IMixedRealitySpeechHandler.OnSpeechKeywordRecognized(SpeechEventData)
 Microsoft.MixedReality.Toolkit.Input.<>c:<.cctor>b__244_38(IMixedRealitySpeechHandler, BaseEventData)
 Microsoft.MixedReality.Toolkit.BaseEventSystem:HandleEvent(BaseEventData, EventFunction`1)
 Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem:DispatchEventToGlobalListeners(BaseInputEventData, EventFunction`1)
 Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem:HandleEvent(BaseEventData, EventFunction`1)
 Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem:RaiseSpeechCommandRecognized(IMixedRealityInputSource, RecognitionConfidenceLevel, TimeSpan, DateTime, SpeechCommands)
 Microsoft.MixedReality.Toolkit.Windows.Input.WindowsSpeechInputProvider:OnPhraseRecognized(ConfidenceLevel, TimeSpan, DateTime, String)
 Microsoft.MixedReality.Toolkit.Windows.Input.WindowsSpeechInputProvider:KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs)
 UnityEngine.Windows.Speech.PhraseRecognizer:InvokePhraseRecognizedEvent(String, ConfidenceLevel, SemanticMeaning[], Int64, Int64)

There's a similar unresolved issue here as well - https://docs.microsoft.com/en-us/answers/questions/378610/getting-started-with-azure-spatial-anchors-createa.html?childToView=624393#answer-624393

Posting here for visibility and to see if there's any resolution.

msftradford commented 2 years ago

Hi @rishabhaggarwal2, thanks for reaching out! Have you had the opportunity to run the ASA Unity sample project here? Can you confirm if SessionUpdated and anchor creation work with that project? Does your project have an enabled ARAnchorManager and SpatialAnchorManager in the scene? Thanks!

no-response[bot] commented 2 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

rishabhaggarwal2 commented 2 years ago

Hi sorry for the delay - I wasn't able to find this thread again. i'm still working on this and was able to create and locate anchors as long as they were in the same session. Across multiple sessions, they would only be located at origin (0,0,0,)

I followed the instructions and updated my ASA to 2.11.0 instead of 2.9.0

Now, I get

InvalidOperationException: ARAnchor still pending
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <00000000000000000000000000000000>:0 
  at AnchorStoreManager+<CreateAnchor>d__14.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.InvokeAction (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.AwaitTaskContinuation.RunCallback (System.Threading.ContextCallback callback, System.Object state, System.Threading.Tasks.Task& currentTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task task, System.Boolean canInlineContinuationTask) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishContinuations () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageThree () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.FinishStageTwo () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task.Finish (System.Boolean bUserDelegateExecuted) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.Task`1[TResult].TrySetException (System.Object exceptionObject) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].SetException (System.Exception exception) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.InvokeMoveNext (System.Object stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation+<>c.<.cctor>b__7_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 
  at Microsoft.MixedReality.WorldLocking.Core.ResourceMirror+DestroyResource`1[ResourceType].Invoke (ResourceType resource) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.WorkRequest:Invoke()
UnityEngine.UnitySynchronizationContext:Exec()
UnityEngine.UnitySynchronizationContext:ExecuteTasks()

when trying to create

and

InvalidOperationException: Could not find an ARAnchor associated with the CloudSpatialAnchor

when trying to find and apply pose

rishabhaggarwal2 commented 2 years ago

Creation Code

 public async void CreateAnchor() {
    var localAnchor = Instantiate(this.SpherePrefab, this.PlacementDisc.transform.position,
      this.PlacementDisc.transform.rotation);
    localAnchor.AddComponent<CloudNativeAnchor>();
    StatusText.GetComponent<TextMeshPro>().text = "anchored at" + localAnchor.transform.position;
    CloudNativeAnchor cloudNativeAnchor = localAnchor.GetComponent<CloudNativeAnchor>();

    if (cloudNativeAnchor.CloudAnchor == null) {
      StatusText.GetComponent<TextMeshPro>().text = cloudNativeAnchor.isActiveAndEnabled ? "yayy" : "noo";
      await cloudNativeAnchor.NativeToCloud();
      StatusText.GetComponent<TextMeshPro>().text = "received native to cloud";
    }

    CloudSpatialAnchor cloudAnchor = cloudNativeAnchor.CloudAnchor;
    //cloudAnchor.AppProperties[@"model-type"] = @"frame";
    cloudAnchor.AppProperties[@"label"] = @"testing123";
    await this.cloudSession.CreateAnchorAsync(cloudAnchor);
    StatusText.GetComponent<TextMeshPro>().text = "created cloud anchor " + cloudAnchor.Identifier + " at " + localAnchor.transform.position;
    Debug.Log(cloudAnchor.Identifier + " created at " + cloudAnchor.GetPose().position);
    identifier = cloudAnchor.Identifier;
    SaveAzureAnchorIdToDisk();

    localAnchor.GetComponent<Renderer>().material.color = Color.blue;
    localAnchor.SetActive(false);
    GameObject.Destroy(localAnchor);
  }

Finding code:

 public void LoadAnchors()
    {
      if (!HasAnchor()) {
        GetAzureAnchorIdFromDisk();
      }
        AnchorLocateCriteria criteria = new AnchorLocateCriteria();
        // @"6a13f5a0-c636-4ca5-b0d5-b33b8294b864"
        criteria.Identifiers = new string[] { identifier,  @"6a13f5a0-c636-4ca5-b0d5-b33b8294b864"};
        StatusText.GetComponent<TextMeshPro>().text = "Looking for " + criteria.Identifiers[0];
        this.cloudSession.CreateWatcher(criteria);

        this.cloudSession.AnchorLocated += (object sender, AnchorLocatedEventArgs args) =>
        {
            switch (args.Status)
            {
                case LocateAnchorStatus.Located:
                    CloudSpatialAnchor foundAnchor = args.Anchor;
                    UnityDispatcher.InvokeOnAppThread(() => {

                      var anchorPose = foundAnchor.GetPose();
                      StatusText.GetComponent<TextMeshPro>().text = "anchor found " + anchorPose.position + foundAnchor.Identifier + " at ";
                      Debug.Log( "anchor found " + foundAnchor.Identifier + " at " + anchorPose.position);
                      var locatedAnchorObject = GameObject.Instantiate(this.SpherePrefab, anchorPose.position,
                        anchorPose.rotation);
                      locatedAnchorObject.AddComponent<CloudNativeAnchor>();
                      locatedAnchorObject.GetComponent<Renderer>().material.color = Color.green;

                      locatedAnchorObject.GetComponent<CloudNativeAnchor>().CloudToNative(foundAnchor);
                      Debug.Log("Located anchor object at" + locatedAnchorObject.transform.position + " local " + locatedAnchorObject.transform.localPosition);
                      //var importAndAttachScript = FindObjectOfType<ImportAndAttachPointCloud>();
                      //importAndAttachScript.GenerateSequence(locatedAnchor.transform.position);
                    });
                    // Go add your anchor to the scene...
                    break;
                case LocateAnchorStatus.AlreadyTracked:
                    CloudSpatialAnchor trackedAnchor = args.Anchor;
                    UnityDispatcher.InvokeOnAppThread(() => {
                      var anchorPose = trackedAnchor.GetPose();
                      StatusText.GetComponent<TextMeshPro>().text = "anchor already tracked " + trackedAnchor.Identifier + " at " + anchorPose.position;
                      Debug.Log( "anchor found " + trackedAnchor.Identifier + " at " + anchorPose.position);
                      var locatedAnchorObject = GameObject.Instantiate(this.SpherePrefab, anchorPose.position,
                        anchorPose.rotation);
                      locatedAnchorObject.AddComponent<CloudNativeAnchor>();
                      locatedAnchorObject.GetComponent<Renderer>().material.color = Color.green;

                      locatedAnchorObject.GetComponent<CloudNativeAnchor>().CloudToNative(trackedAnchor);
                      //var importAndAttachScript = FindObjectOfType<ImportAndAttachPointCloud>();
                      //importAndAttachScript.GenerateSequence(locatedAnchor.transform.position);
                    });

                    // This anchor has already been reported and is being tracked
                    break;
                case LocateAnchorStatus.NotLocatedAnchorDoesNotExist:
                    UnityDispatcher.InvokeOnAppThread(() => {
                      StatusText.GetComponent<TextMeshPro>().text = "anchor does not exist";
                    });
                    // The anchor was deleted or never existed in the first place
                    // Drop it, or show UI to ask user to anchor the content anew
                    break;
                case LocateAnchorStatus.NotLocated:
                    UnityDispatcher.InvokeOnAppThread(() => {
                      StatusText.GetComponent<TextMeshPro>().text = "anchor couldn't be located";
                    }); 
                    // The anchor hasn't been found given the location data
                    // The user might in the wrong location, or maybe more data will help
                    // Show UI to tell user to keep looking around
                    break;
            }

        };
    }
msftradford commented 2 years ago

Hey @rishabhaggarwal2, thanks for the update. I believe that the issue may be with the calls to CloudSpatialAnchor.GetPose(). To use that function, you will want an enabled SpatialAnchorManager in your scene and you will want to interface with SpatialAnchorManager instead of CloudSpatialAnchorSession directly. Our Unity HoloLens Tutorial shows how to do this (as does our Unity sample app). I would do a quick test and comment-out the GetPose() calls to confirm this is the case. Let us know if that works. Thanks!

rishabhaggarwal2 commented 2 years ago

Thanks @msftradford - so I updated OpenXR to 1.2.1, ASA to 2,11,0 as per the tutorial

Also changed everything to use the SpatialAnchorManager as per the tutorial.

I get the following list of errors now:

Unable to register IMixedRealitySpatialAwarenessObserver data provider (Windows Mixed Reality Spatial Mesh Observer) because the value of concreteType is null.
This may be caused by code being stripped during linking. The link.xml file in the MixedRealityToolkit.Generated folder is used to control code preservation.
More information can be found at https://docs.unity3d.com/Manual/ManagedCodeStripping.html.

StartSessionAsync called with but no session. Creating one.

Need an enabled ARAnchorManager in the scene

InvalidOperationException: SpatialAnchorManager is improperly configured.

InvalidOperationException: ARAnchor still pending

And after all this, it doesn't end up creating an Anchor.

Here's what my gameobject with all the scripts looks like: image

msftradford commented 2 years ago

@rishabhaggarwal2, thanks for the additional info. Because we cannot find the ARAnchorManager in the scene, SpatialAnchorManager does not get configured properly, and as a result the calls into SpatialAnchorManager will not work. I do see from your screenshot that ARAnchorManager and ARSessionOrigin are added to some GameObject in the inspector, so I'm not sure why we can't find the ARAnchorManager in SpatialAnchorManager.Start(). For this, we are using Unity's built-in function, Object.FindObjectOfType(), to find the ARAnchorManager in the scene and that function must be returning null for you to see that error message. Can you verify that you've also checked the capabilities and main camera settings? Is it possible that the owning GameObject is in a disabled state? Does this application have multiple scenes and is it possible that the scene hasn't finished loading? Does the tutorial work for you out-of-the-box without any changes?

no-response[bot] commented 2 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.