Azure / azure-spatial-anchors-samples

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

InvalidOperationException: SpatialAnchorManager is improperly configured. #350

Closed sana2024 closed 2 years ago

sana2024 commented 2 years ago

I have azure spatial anchor with unity and MRTK (Introduction to the Multi-user capabilities tutorials) the session starts find but when I try to change between scenes it crashes

I have a scene for login and the azure spatial anchor scene I login and jump to the ASA scene just fine and I am also able to start the session and locate anchors but when I go back to signup scene it throws this error: InvalidOperationException: Anchor manager has no subsystem

and when I open the ASA scene again and click start session it crashes and shows this error: InvalidOperationException: SpatialAnchorManager is improperly configured.

is there a way I can change scenes without this issue?? note: I stop the session when the scene changes using cloudManager.DestroySession()

I'm using iPhone 11 AR foundation 4.1.1

here is the full debug error on Xcode: Uploading Crash Report InvalidOperationException: SpatialAnchorManager is improperly configured. at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorManager+d23.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorManager.EnsureValidConfiguration (System.Boolean disable, System.Boolean exception) [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorManager+d45.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorManager.CreateSessionAsync () [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript+d28.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript.StartAzureSession () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.Process () [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.ThrowForNonSuccess (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.SpatialAnchorManager+d45.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorManager.CreateSessionAsync () [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript+d28.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript.StartAzureSession () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.Process () [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.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript+d28.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 at AnchorModuleScript.StartAzureSession () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 at Microsoft.MixedReality.Toolkit.Input.MixedRealityInputModule.Process () [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.b__6_0 (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 at System.Threading.SendOrPostCallback.Invoke (System.Object state) [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00000] in <00000000000000000000000000000000>:0 at UnityEngine.UnitySynchronizationContext.Exec () [0x00000] in <00000000000000000000000000000000>:0 UnityEngine.WorkRequest:Invoke() UnityEngine.UnitySynchronizationContext:Exec()

Varnauld commented 2 years ago

@darax would you be available to help here? thanks! (cc @pamistel )

darax commented 2 years ago

Hi @sana2024, When ASA raises this error in most cases it will also log what it is missing before throwing the exception. There is a good chance that whatever is missing was destroyed when switching scenes. To get around this there are a couple of choices: a) you can use do not destroy on load. A script that calls this API should be attached to the root of the object with all of the ARfoundation scene setup. b) you can make a prefab that will be instantiated with all of the ARFoundation prerequisites, like the ARSessionOrigin and the ARAnchorManager.

Varnauld commented 2 years ago

@sana2024 - I'm going to close this item, but please reach out if you have any follow-up questions, thanks!

lightlessdays commented 2 years ago

I got the same error. This is what I was doing wrong: When I closed Unity, my keys got deleted, so go to the GameObject that contains SpatialAnchorManager script and re-enter your keys. image

Varnauld commented 2 years ago

Thank you for reaching out - Tagging @darax to provide some input here, thank you