# Unity, OpenXR plane tracking fatal error on begin plane detection

**URL:** <https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786>\
**Category:** Unity Development\
**Tags:** openxr, plane-detection\
**Created:** [July 16, 2024, 3:01pm UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786 "2024-07-16T15:01:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dean](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dean](https://forum.magicleap.cloud/u/dean)\
**Post date:** [July 16, 2024, 3:01pm UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/1 "2024-07-16T15:01:54Z")

</div>

Have setup a XR Rig with AR Session and AR Plane Manager. Have checked and activated permissions for Spatial Mapping. When running on device i get the following error: Error: XrBeginPlaneDetection in the Magic Leap API failed. Reason: SpaceNotLocatableEXT.

Any help with understanding why this error is occurring would be great. Thanks!

**Unity Editor version** (if applicable): 2022.3.37f1  
**ML2 OS version** : 1.8.0  
**MLSDK version** : 2.3.0

**Error messages from logs** (syntax-highlighting is supported via Markdown):

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [July 16, 2024, 3:15pm UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/2 "2024-07-16T15:15:15Z")

</div>

What this error is telling you is that the base space you are passing into the plane query is not locatable and thus the runtime cannot answer your query at all. When you receive that specific error try again in a future frame when hopefully the floor level is established.

Make sure that you have the Reference Space feature enabled. Then you can set your xr origin to Device, so it will not have to wait for the floor height to be established.

> **[Reference Space Overview | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/reference-space/reference-space-overview/)**
>
> Reference Spaces are different methods of defining the origin and orientation of the coordinate system used by the device within your application. They affect how the device tracks the position and rotation of the user and the environment. Different...

---

<div class="post-metadata">

**Author:** ![dean](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dean](https://forum.magicleap.cloud/u/dean)\
**Post date:** [July 16, 2024, 3:36pm UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/3 "2024-07-16T15:36:19Z")

</div>

Hi @kbabilinski thankyou for the explanation. I found that the error can also occur if you attempt a query before the permission has been granted. I have resolved this in my code but planes are still not detecting.

I can confirm reference space feature is enabled and XR Origin is set to Device. I also call the query on the main Update loop; it never responds with any plane being created via the AR Plane Manager. My code is pretty much identical to the sample here [[Planes Query | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/plane-detection/openxr-unity-planes-query/)].

I installed the Unity XR Simulator to see if it would work there. When running with this it rarely detects a plane in the editor (approx. 1 in 20 runs) and the plane classification is always returned as "None".

Any ideas on what could be causing planes to not be detected?

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [July 16, 2024, 5:28pm UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/4 "2024-07-16T17:28:24Z")

</div>

Interesting, I was not able to reproduce this using the latest OS and SDK.

I used the `PlaneExample` script from the documentation and added it to the Unity Examples Project. (I had to rename the script to `PlaneExample2` so it would not conflict with the existing `PlaneExample` script).

Once I renamed it, I opened the `Hello Cube` scene and added the `PlaneExample2` component to an empty GameObject. Then I added the `ARPlaneManager` component to the XR Origin object and assigned the demo Plane Prefab from the `Assets/Prefabs/` folder.

When I ran the example application, the scene prompted me for permissions and then displayed the planes on the flat surfaces.

---

<div class="post-metadata">

**Author:** ![dean](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dean](https://forum.magicleap.cloud/u/dean)\
**Post date:** [July 18, 2024, 8:48am UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/5 "2024-07-18T08:48:59Z")

</div>

I found the issue. It was an error on my part when copying the example from the website I didn't copy the 'using' section from the top of the class. VS then auto filled these to use the old ML ones instead of the OpenXR. It still compiled as the functions called are identical but on device it threw the error I posted originally!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [August 2, 2024, 8:49am UTC](https://forum.magicleap.cloud/t/unity-openxr-plane-tracking-fatal-error-on-begin-plane-detection/3786/6 "2024-08-02T08:49:48Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
