# ML Compat Extension (XR\_ML\_compat) support

**URL:** <https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928>\
**Category:** OpenXR\
**Created:** [November 28, 2023, 10:12pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928 "2023-11-28T22:12:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![emaschino](https://avatars.discourse-cdn.com/v4/letter/e/13edae/32.png) [@emaschino](https://forum.magicleap.cloud/u/emaschino)\
**Post date:** [November 28, 2023, 10:12pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/1 "2023-11-28T22:12:29Z")

</div>

Hi,

I need to locate the reference space associated with an anchor created in MLPerception. To this end, I've successfully enabled `XR_ML_compat` extension in my code. But at runtime, I'm getting error `XR_ERROR_FUNCTION_UNSUPPORTED` when trying to get `xrCreateSpaceFromCoordinateFrameUIDML` function pointer. This is with up-to-date ML SDK 1.4.0 and OS 1.4.1 (secure). Any suggestion?

I've checked the OpenXR samples provided with ML SDK. But besides wrapping support for `XR_ML_compat` in `MLCompat` class in $ENV{MLSDK}/v1.4.0/samples/openxr\_samples/xraf/src/Extensions/MLCompat.cpp in the same way as I did, I cannot find any example using `XR_ML_compat` (or `MLCompat` class).

If it does matter, I'm using the standard OpenXR loader (as recommended in [1]). I've noticed in the source code that support for `XR_ML_compat` extension is guarded with `XR_USE_PLATFORM_ML` that is nowhere set! So just in case, I've recompiled the loader from source, defining `XR_USE_PLATFORM_ML` (once having successfully located ML SDK with the provided FindMagicLeap.cmake script) and `#include`'d `<ml_coordinate_frame_uid.h>` in src/common/xr\_dependencies.h to fix undefined `MLCoordinateFrameUID` error in struct `XrCoordinateSpaceCreateInfoML` in include/openxr/openxr\_platform.h. I don't know if this is the correct way to rebuild the OpenXR loader with the Magic Leap extensions built-in as I cannot find any documentation on the subject. So, don't hesitate to point me in the right direction if I'm wrong. BTW, FindMagicLeap.cmake hijacks any CMake project name set, resulting in a lot of side effects. So be sure to first include this script before defining your CMake project name (or including other `find_package` directives).

Out of curiosity, since `xrCreateSpaceFromCoordinateFrameUIDML` requires a `MLCoordinateFrameUID` obtained from MLPerception, does it mean that both the MLPerception module and OpenXR runtime are tracking the world in background?

Thanks.

[1] [OpenXR Setup | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/native/native-openxr-setup/#)

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [November 29, 2023, 7:38pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/2 "2023-11-29T19:38:17Z")

</div>

Hi @emaschino,

Welcome to the Magic Leap 2 Developer Forums. We are so grateful to have you here engaging with us.

Regarding this issue; are you receiving an error on a call to xrGetInstanceProcAddr? If so, you may be on an older OS. This does not appear to be the case for you, though. If not, you may not have enabled XR\_ML\_compat correctly in the xrCreateInstance call.

Let me know if you have any further questions,

Best,

El

---

<div class="post-metadata">

**Author:** ![emaschino](https://avatars.discourse-cdn.com/v4/letter/e/13edae/32.png) [@emaschino](https://forum.magicleap.cloud/u/emaschino)\
**Post date:** [November 30, 2023, 2:38pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/3 "2023-11-30T14:38:16Z")

</div>

Hi @etucker,

Thanks for the warm welcome and your answer.

Yes, when I was saying that I'm getting error `XR_ERROR_FUNCTION_UNSUPPORTED` when trying to get `xrCreateSpaceFromCoordinateFrameUIDML` function pointer, this is the error returned by `xrGetInstanceProcAddr`.

As I said, I'm running latest OS 1.4.1. Unless yet another update started to deploy...

I've double-checked that `XR_ML_COMPAT_EXTENSION_NAME` is among the requested extensions passed to `xrCreateInstance`. And I've also double-checked that `XR_ML_compat` is reported as enabled.

As I was also asking, do I need to rebuild the OpenXR loader with `XR_USE_PLATFORM_ML` set to have this extension correctly defined? Where are then the building instructions, please? There's nothing on the Khronos resources about the `XR_USE_PLATFORM_ML` define.

As an alternative, I've extracted libopenxr\_loader.so from [1] and can't find any reference to `xrCreateSpaceFromCoordinateFrameUIDML` either. Is this expected?

[1] [https://github.com/KhronosGroup/OpenXR-SDK-Source/releases/download/release-1.0.31/openxr\_loader\_for\_android-1.0.31.aar](https://github.com/KhronosGroup/OpenXR-SDK-Source/releases/download/release-1.0.31/openxr_loader_for_android-1.0.31.aar)

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [December 1, 2023, 10:42pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/4 "2023-12-01T22:42:41Z")

</div>

I have reached out to our team regarding this issue and I will report back as soon as I learn more details. Thank you for your patience.

Best,

El

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [December 4, 2023, 5:27pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/5 "2023-12-04T17:27:49Z")

</div>

> [@emaschino](#):
>
> and can't find any reference to `xrCreateSpaceFromCoordinateFrameUIDML` either

This is expected as this will happen at runtime, not in the compled binary. What is important is to check that the extension is actually advertised by the runtime.

Would you mind posting the list of extensions reported by xrEnumerateInstanceExtensionProperties?

Also, please make sure that the call to xrCreateInstance that you have the name exactly as advertised by the runtime.

Could you please post the exact strings that you are passing to xrGetInstanceProcAddr and if you are using an instance when calling that function.

Also, if you would like, you can privately or publicly share the relevant code snippet. This may help speed up the process.

Best,

El

---

<div class="post-metadata">

**Author:** ![emaschino](https://avatars.discourse-cdn.com/v4/letter/e/13edae/32.png) [@emaschino](https://forum.magicleap.cloud/u/emaschino)\
**Post date:** [December 6, 2023, 2:54pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/6 "2023-12-06T14:54:38Z")

</div>

@etucker Thank you for your answer and sorry for the delay.

Short story: I don't know what fixed my inability to retrieve `xrCreateSpaceFromCoordinateFrameUIDML` function pointer, but it's now working 🙂

Long story: A lot of things have changed since my last post. (1) I've rebuilt the OpenXR loader to latest release 1.0.32.1. For the interested people, I didn't have to define `XR_USE_PLATFORM_ML` while building. (2) I thought that I was using MLSDK 1.4.0. From the plethora of warning messages that I'm now seeing (because of MLCamera deprecation that my code also relies upon), I was probably compiling with older MLSDK 1.4.0-dev2 at the time, not the final 1.4.0 release. (3) I've also experienced a lot of issues with unresolved symbols in my code although I was certain that I was linking against the right libraries. It turns out that Build -\> Clean Project in Android Studio seems not to clean everything properly. Manually deleting the build and intermediate object directories fixed the linking. With all these things put in place, I can now successfully call `xrCreateSpaceFromCoordinateFrameUIDML` whereas I didn't changed a single line of code w.r.t. anchor creation.

So, now that I can interop between MLPerception and OpenXR, I tried to locate in OpenXR the space associated with the anchor created with MLPerception. It's kinda working as xrLocateSpace returns a location. But neither `XR_SPACE_LOCATION_POSITION_VALID_BIT` nor `XR_SPACE_LOCATION_POSITION_TRACKED_BIT` are set. Is this expected? As I was wondering at the end of my first post, is it because both the MLPerception module and OpenXR runtime are tracking the world concurrently in background?

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [December 8, 2023, 12:31am UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/7 "2023-12-08T00:31:48Z")

</div>

I'm so glad you were able to get it working. We appreciate the detailed explanation as well.

> [@emaschino](#):
>
> So, now that I can interop between MLPerception and OpenXR, I tried to locate in OpenXR the space associated with the anchor created with MLPerception. It's kinda working as xrLocateSpace returns a location. But neither `XR_SPACE_LOCATION_POSITION_VALID_BIT` nor `XR_SPACE_LOCATION_POSITION_TRACKED_BIT` are set. Is this expected? As I was wondering at the end of my first post, is it because both the MLPerception module and OpenXR runtime are tracking the world concurrently in background?

Would you mind creating a separate post for this? We are going to close this topic.

Best,

El

---

<div class="post-metadata">

**Author:** ![emaschino](https://avatars.discourse-cdn.com/v4/letter/e/13edae/32.png) [@emaschino](https://forum.magicleap.cloud/u/emaschino)\
**Post date:** [December 11, 2023, 1:42pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/8 "2023-12-11T13:42:22Z")

</div>

Done. Please have a look to [Locating MLSpatialAnchor in OpenXR](https://forum.magicleap.cloud/t/locating-mlspatialanchor-in-openxr/2955).

---

<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:** [December 26, 2023, 1:42pm UTC](https://forum.magicleap.cloud/t/ml-compat-extension-xr-ml-compat-support/2928/9 "2023-12-26T13:42:39Z")

</div>

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