Azure/azure-spatial-anchors-samples

NullReferenceException: Object reference not set to an instance of an object.

Opened this issue · 15 comments

Description

Hello, I am new to Unity and I tried to play with this mode. I finished the whole process successfully. However, when I try to play this on Hololens 2, I could not even start the process.

Steps to reproduce the issue

When I clicked on StartAzureSession button, the error message was posted on the debug window.
NullReferenceException: Object reference not set to an instance of an object.

I have no idea why this would happen. Could some one please help me with it?

Expected behavior

I expect to start building an anchor.

Screenshots

Screenshot (5)

Development information (please complete the following information)

  • OS: Windows
  • Development Platform\Version: Unity 2020.3.35f1
  • Azure Spatial Anchors SDK version:2.10.2

AR Device information (please complete the following information):

  • Device: Hololens 2

Additional context

Add any other context about the problem here.

darax commented

Hi @xueyuancao0218
If you go to the device portal website on your device, and find the application's folder, there is a log file that might help identify what is going wrong. You might also consider starting with one of the samples offered on this repo.

image

Hi @darax

I'm also facing the same issue. I have attached the log file here.Pls help me to fix this.

UnityPlayer.log
.

darax commented

@gowtthi I see two issues in the log.

  1. There are a lot of MRTK errors in the log that should probably be addressed by the MRTK github here: https://github.com/microsoft/MixedRealityToolkit-Unity
    NullReferenceException: Object reference not set to an instance of an object.
    at Microsoft.MixedReality.Toolkit.Utilities.BaseMixedRealityLineDataProvider.DistortPoint (UnityEngine.Vector3& point, System.Single normalizedLength) [0x00000] in <00000000000000000000000000000000>:0
    at Microsoft.MixedReality.Toolkit.Utilities.BaseMixedRealityLineDataProvider.GetPoint (System.Single normalizedLength) [0x00000] in <00000000000000000000000000000000>:0
    at Microsoft.MixedReality.Toolkit.Utilities.MixedRealityLineRenderer.UpdateLine () [0x00000] in <00000000000000000000000000000000>:0

  2. It did appear to create an anchor, and either a user or script error has resulted in the session being stopped when the request to search for the anchor is made. I've trimmed down the log to make this more clear:
    AnchorModuleScript.StartAzureSession()
    Starting Azure session... please wait...
    Azure session started successfully
    AnchorModuleScript.CreateAzureAnchor()
    Local anchor created
    Creating Azure anchor... please wait...
    Azure anchor with ID '[GUID]' created successfully
    Current Azure anchor ID updated to '[GUID]'
    AnchorModuleScript.StopAzureSession()
    Stopping Azure session... please wait...
    Azure session stopped successfully
    AnchorModuleScript.StopAzureSession() WAS THIS MEANT TO BE A START??
    Stopping Azure session... please wait...
    StopSession called but no session has been started.
    Azure session stopped successfully
    AnchorModuleScript.RemoveLocalAnchor()
    Local anchor deleted succesfully
    AnchorModuleScript.FindAzureAnchor()
    Anchor locate criteria configured to look for Azure anchor with ID '[GUID]'
    InvalidOperationException: Cannot create watchers when session is not active.

(edit: removed assertion that OpenXR isn't supported in the current release)

darax commented

@xueyuancao0218 looking more closely at your post, are you trying to get this working in the unity editor? If so that scenario isn't supported; you need to build the unity project as a visual studio solution, and then deploy that solution to your HoloLens 2 device.

@xueyuancao0218 looking more closely at your post, are you trying to get this working in the unity editor? If so that scenario isn't supported; you need to build the unity project as a visual studio solution, and then deploy that solution to your HoloLens 2 device.

Thanks for replying to me. However, I did the experiments on Hololens 2.

darax commented

@xueyuancao0218 thanks for confirming. Were you able to get the log?

@xueyuancao0218 thanks for confirming. Were you able to get the log?

I tried to do so, but I have trouble in locating the file. In the device portal website, I could not find the log of this project.

Is there any other way that I could use to locate the log file?

darax commented

The device portal website is the only way I'm aware of.

The device portal website is the only way I'm aware of.

I tried to find the log file in device portal website. However, I could not find the correct unity project in it. Could you help me with it? The attachment is the screenshot of my computer. I have no idea why this would happen. Did I do something wrong?
Screenshot (5)

darax commented

Looks like it's the second one in the list.

Looks like it's the second one in the list.

I am sorry, but that is another project that I have been working on.

darax commented

Did both projects start with the same unity project? It might be that the last deployed project is what is actually on the device.
These are the possibilities:

  1. A bug in the HoloLens OS preventing the project from being seen in the device portal
  2. That second entry is the project
  3. The project isn't on the device

It would be good to
a. Reproduce the problem
b. Grab the log from that second entry
c. Read it to see if it looks to be from the ASA Tutorial or from the other tutorial you are working on

If it's from the ASA tutorial, I'm happy to look through it if you post it.

darax commented

BTW, OpenXR does work in the released version of ASA. There were some temporary internal changes that confused me.

@xueyuancao0218

We just released a new version of SDK 2.13.0.
Could you try this new version of SDK to see if the problem still persists please?
Thank you very much.

I have very same problem that indicates null object when I clicked Start Session Button as I run this sample project on Hololens2. If you solve the problem, Can I know your solution??
My environment is
OS : win10
Unity : 2020.3.24f1
ASA : 2.13 (failed at 2.10 & 2.11)
OpenXR : 1.2.1
MRTK Foundation 2.7.3
image