Azure / azure-spatial-anchors-samples

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

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

Open 1uan-yuan opened 2 years ago

1uan-yuan commented 2 years ago

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)

AR Device information (please complete the following information):

Additional context

Add any other context about the problem here.

darax commented 2 years ago

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

gowtthi commented 2 years ago

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 2 years ago

@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 2 years ago

@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.

1uan-yuan commented 2 years ago

@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 2 years ago

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

1uan-yuan commented 2 years ago

@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 2 years ago

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

1uan-yuan commented 2 years ago

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 2 years ago

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

1uan-yuan commented 2 years ago

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 2 years ago

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 2 years ago

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

XiangyuL-Microsoft commented 2 years ago

@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.

kookoo9999 commented 2 years ago

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