Azure / azure-spatial-anchors-samples

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

Issue when trying to create Azure Anchor #269

Closed KillTheProcess23 closed 3 years ago

KillTheProcess23 commented 3 years ago

Hi! Im working on Hololens 2 and having problem creating anchors with CloudSpatialAnchor

this is the code (which i think could be wrong)

public async void CreateAnchor() {
        if (localAnchor == null) {
            localAnchor = GameObject.Instantiate(AnchorPrefab, this.transform.position, this.transform.rotation);
            localAnchor.AddComponent<CloudNativeAnchor>();
        } else {
            localAnchor.transform.position = this.transform.position;
            localAnchor.transform.rotation = this.transform.rotation;
        }

        Debug.Log("Local Anchor created");
        try {
            CloudNativeAnchor currentCloudAnchor = localAnchor.GetComponent<CloudNativeAnchor>();
            if (currentCloudAnchor.CloudAnchor == null) { currentCloudAnchor.NativeToCloud(); }
            CloudSpatialAnchor cloudAnchor = currentCloudAnchor.CloudAnchor;

            /*currentCloudAnchor = new CloudSpatialAnchor();
            CloudNativeAnchor localAnchor = this.localAnchor.GetComponent<CloudNativeAnchor>();
            currentCloudAnchor.LocalAnchor = await localAnchor.NativeAnchor.GetPointer();*/
        } catch(Exception e) {
            Debug.Log("Exception: " + e);
        }
        //currentCloudAnchor.AppProperties[@"name"] = this.name;

        Debug.Log("Starting creating");
        await Task.Run(async () => {
            // Wait for enough data about the environment.
            while (recommendedForCreate < 1.0F) {
                await Task.Delay(330);
            }

            bool success = false;
            try {
                QueueOnUpdate(() => {
                    Debug.Log("Saving to azure...");
                });

                await cloudSpatialAnchorSession.CreateAnchorAsync(currentCloudAnchor);
                success = currentCloudAnchor != null;

                if (success) {
                    // Record the identifier to locate.
                    currentAzureAnchorID = currentCloudAnchor.Identifier;

                    QueueOnUpdate(() => {
                        //saving feedback blue
                    });

                    Debug.Log("ASA Info: Saved anchor to Azure Spatial Anchors! Identifier: " + currentAzureAnchorID);
                    SaveAzureAnchorIdToPlayerPrefs();
                    //success green;
                }
                else {
                    //failure feedback  red
                    Debug.LogError("ASA Error: Failed to save, but no exception was thrown.");
                }
            }
            catch (Exception ex) {
                QueueOnUpdate(() => {
                    //failure feedback red

                });
                Debug.LogError("ASA Error: " + ex.Message);
            }
        });
    }

i get NullReferenceException on if (currentCloudAnchor.CloudAnchor == null) { currentCloudAnchor.NativeToCloud(); } and cant proceed.

Im using Azure SDK 2.9 and this so im trying to adapt cause i cant find newer documentation. But i can't make it work. Should i use SpatialAnchorManager?

gllebede commented 3 years ago

May I ask you to post here a NullReferenceException callstack? And, just to rule simple things out, the currentCloudAnchor isn't null, right?

AdCCooN commented 3 years ago

Hello guys,

Just these days I am trying to run the sample unity project on Hololens 2 and Unity 2020.3.6f1.

I configured the project for Hololens 2 and I have also noticed that I receive an exception on the flow for creating the cloud spatial anchor. I tried to debug and the exception is more exactly received on (part of SpatialAnchorsExtensions.cs):

public static async Task<CloudSpatialAnchor> ToCloud(this NativeAnchor anchor)
{
    // Validate
    if (anchor == null) { throw new ArgumentNullException(nameof(anchor)); }

    // Get the native pointer
    Task<IntPtr> ptrTask = anchor.GetPointer(); **<--- Here the exception occurs** 
    await ptrTask;

    // Create the cloud version
    CloudSpatialAnchor cloudSpatialAnchor = new CloudSpatialAnchor();

    // Set the local pointer
    cloudSpatialAnchor.LocalAnchor = ptrTask.Result;

    // Done!
    return cloudSpatialAnchor;
}

Exception: (from ptrTask)

"System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent.get_WorldAnchorHandle () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.GetPointer (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.ToCloud (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud (System.Boolean useExisting) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase+<SaveCurrentObjectAnchorToCloudAsync>d__41.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.SaveCurrentObjectAnchorToCloudAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript+<AdvanceDemoAsync>d__14.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript.AdvanceDemoAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.<OnSelectInteraction>b__38_0 () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.UnityDispatcher.Update () [0x00000] in <00000000000000000000000000000000>:0 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.ToCloud (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud (System.Boolean useExisting) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase+<SaveCurrentObjectAnchorToCloudAsync>d__41.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.SaveCurrentObjectAnchorToCloudAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript+<AdvanceDemoAsync>d__14.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript.AdvanceDemoAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.<OnSelectInteraction>b__38_0 () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.UnityDispatcher.Update () [0x00000] in <00000000000000000000000000000000>:0 \r\n --- End of inner exception stack trace ---\r\n---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.\r\n at Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent.get_WorldAnchorHandle () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<GetPointer>d__7.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.GetPointer (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.ToCloud (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud (System.Boolean useExisting) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase+<SaveCurrentObjectAnchorToCloudAsync>d__41.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.SaveCurrentObjectAnchorToCloudAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript+<AdvanceDemoAsync>d__14.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript.AdvanceDemoAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.<OnSelectInteraction>b__38_0 () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.UnityDispatcher.Update () [0x00000] in <00000000000000000000000000000000>:0 \r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions+<ToCloud>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.SpatialAnchorExtensions.ToCloud (Microsoft.Azure.SpatialAnchors.Unity.ARFoundation.UnityARFoundationAnchorComponent anchor) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__4.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud (System.Boolean useExisting) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor+<NativeToCloud>d__5.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.CloudNativeAnchor.NativeToCloud () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase+<SaveCurrentObjectAnchorToCloudAsync>d__41.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.SaveCurrentObjectAnchorToCloudAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript+<AdvanceDemoAsync>d__14.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 \r\n at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.AzureSpatialAnchorsBasicDemoScript.AdvanceDemoAsync () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.Examples.DemoScriptBase.<OnSelectInteraction>b__38_0 () [0x00000] in <00000000000000000000000000000000>:0 \r\n at Microsoft.Azure.SpatialAnchors.Unity.UnityDispatcher.Update () [0x00000] in <00000000000000000000000000000000>:0 <---\r\n"

gllebede commented 3 years ago

Thanks! It was really helpful.

It looks like UnityARFoundationAnchorComponent.WorldAnchor was null. WorldAnchor should not be null if Awake is executed by Unity.

I'll look into this.

AdCCooN commented 3 years ago

@gllebede what I also noticed is the following (SpatialAnchorManager.cs):

protected async virtual void Start()
{
    mainCamera = Camera.main;
    arCameraManager = FindObjectOfType<ARCameraManager>();
    arSession = FindObjectOfType<ARSession>();
    arAnchorManager = FindObjectOfType<ARAnchorManager>();

    // Only allow the manager to start if it is properly configured.
    await EnsureValidConfiguration(disable: true, exception: false);

    arAnchorManager.anchorsChanged += ARAnchorManager_anchorsChanged;
}

For hololens 2 there is no ARCameraManager, ARSession, ARAnchorManager as part of the hololens 2 camera hierachy setup (I am using MRTK) and I didn't found anywhere in the documentation information regarding those aspects. I can confirm that I have removed the checks for those references in the SpatialAnchorManager in order to pass the initialization step of the cloud session. Maybe this is the problem since looking more in the code I think the ARAnchorManager should be used in order to create that WorldAnchor reference ?

msftradford commented 3 years ago

@KillTheProcess23 thanks for sharing your code! I do see one issue: you'll need to await the call to NativeToCloud(). Our samples show how this is done. We recommend using SpatialAnchorManager, especially if you plan to deploy cross-platform.

msftradford commented 3 years ago

@AdCCooN thanks for bringing this to our attention! We are currently working on updating the documentation to explain the Unity scene construction and necessary ARFoundation components.

Here are the required ARFoundation components by platform: HL devices: ARAnchorManager (and ARSessionOrigin) Mobile devices: ARAnchorManager (and ARSessionOrigin), ARCameraManager, ARSession

In the 2.10 release we'll have a fix to only check for the minimum required ARFoundation components by platform.

KillTheProcess23 commented 3 years ago

@KillTheProcess23 thanks for sharing your code! I do see one issue: you'll need to await the call to NativeToCloud(). Our samples show how this is done. We recommend using SpatialAnchorManager, especially if you plan to deploy cross-platform.

Yes! I solved it by switching to SpatialAnchorManager and now everything works fine! For the initial issue, yes it was the await to NativeToCloud(). Thank you

fafux commented 3 years ago

Hi! I have the same problem even if I added the await to NativeToCloud(). I get the InvalidOperationException: Couldn't obtain a native anchor pointer error.

msftradford commented 3 years ago

Hi @fafux, thanks for reaching out! It would be great if you could fill out the bug report template so that we can get info like device, OS, package versions, WinXR or MROpenXR, if the same thing happens in our Unity sample, etc. Thanks!

fafux commented 3 years ago

Description I am working on Hololens 2 and having problem creating anchors with CloudSpatialAnchor. I both followed the tutorial on how to create an anchor with Unity and the tutorial on getting started with azure spatial anchors. In both cases, I get the InvalidOperationException: Couldn't obtain a native anchor pointer error in the code line await cloudNativeAnchor.NativeToCloud();.

Development information (please complete the following information)

AR Device information (please complete the following information):

Additional context The error appears when I try to create a spatial anchor.

msftradford commented 3 years ago

@fafux, sorry to hear that you're still having trouble. I'd prefer to start a new thread entirely so that future developers do not conflate these issues. Would you mind submitting the bug report to create a separate thread? In that thread, can you also let us know if you are able to run the WinXR-based official ASA sample or the official MROpenXR+ASA sample on your device? Thanks!