ML Compat Extension (XR_ML_compat) support


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?


[1] OpenXR Setup | MagicLeap Developer Documentation

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,



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 from [1] and can't find any reference to xrCreateSpaceFromCoordinateFrameUIDML either. Is this expected?


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.



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.



@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 :slight_smile:

Long story: A lot of things have changed since my last post. (1) I've rebuilt the OpenXR loader to latest release 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?

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

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



Done. Please have a look to Locating MLSpatialAnchor in OpenXR.

1 Like

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