How to Stop and Start MLMarkerTracker in Unity MLSDK?

Hello. For our application I need to stop MLMarkerTracker scanning and re-start it in Unity. However, between these two, I stop and destroy the openxr instance and when I return to Unity, I reinitialize openxr instance and restart openxr runtime. And due to this, the MLMarkerTracker's inner native handle gets invalidated and I get an error saying the Handle is not registered. My question is: since the MLMarkerTracker.StopAPI() method is not accessible for me, is there any way that I can explicitly restart the MLMarkerTracker API and singleton instance so that they get assigned a valid handle?

In addition, I have to use the old Unity MLSDK APIs since we are using MRTK3 which is not yet supporting the standard Unity OpenXR Plugin. Also, we start from Unity and kill its openxr instance and then go to a native environment with its own OpenXR instance and then come back to the Unity doing the same.

ML2 OS 1.5.0:
MLSDK 1.5.0:
Host OS Windows: (Windows/MacOS)

To make sure I understand, you are switching between the OpenXR and the Magic Leap XR Loader at runtime? When you transfer between the two runtimes you run into an issue where the API is not able to restart properly because it gets an invalid handle when re-initialized ?

Yes.

Yes. However, if the device goes into sleep mode because for example the user has taken the device off, the Unity based activity goes to OnStop method and when the user comes back the API works properly.
In our logic, we start in the Unity activity. There, we deinit the openxr runtime and then we switch to a native activity and when coming back from the native activity, we have a similar transition. So, technically the unity activity goes into OnStop, however the MLMarkerTracker does not contain a valid handle in this case.

When you say

In our logic, we start in the Unity activity. There, we deinit the openxr runtime and then we switch to a native activity and when coming back from the native activity, we have a similar transition

To make sure I understand the reproduction steps, currently you launch a Unity Application that uses the Magic Leap XR and MRTK 3, once the app is started you disable the loader and open a separate native activity, when returning to the application, you disable the loader in the separate activity and try to re-initialize Magic Leap XR in Unity.

Is the separate Activity a separate application?


I have to use the old Unity MLSDK APIs since we are using MRTK3 which is not yet supporting the standard Unity OpenXR Plugin.

Magic Leap MRTK 3 Open XR Support will be available in the upcoming release, slated for this month.

We do not stop the loader in the start of the unity activity. At some point we do, but not in the beginning. UnityActivity starts and user interacts with it and at some point chooses to switch to another activity which is a Native Activity.

As mentioned, all the transitions happen between activities which are part of the same application.

Good news. Thank you for this information.

Thank you for that information, I have reported this issue to the appropriate team and will keep you updated on it's status.

Would having support for marker tracking and mrtk3 in Unity OpenXR unblock your development?

Yes! It would help us with the proper de-/re-initialization of the openxr runtime instance and session.

Do you mind trying to switch to the OpenXR provider completely now that the Marker Tracker is supported in OpenXR and so it MRTK3?