Error: XrCreatePixelSensor in the Magic Leap API failed. Reason: PixelSensorNotAvailableML

Hello,

Error: XrCreatePixelSensor in the Magic Leap API failed. Reason: PixelSensorNotAvailableML
Error: Unable to create sensor type: Depth Center

I occasionally encounter this error when configuring the pixel sensor, typically when my application doesn’t shut down properly or my cleanup code isn’t executed as expected.
I destroy the pixel sensor in both OnApplicationPause and OnDestroy, using the following call:
pixelSensorFeature.DestroyPixelSensor(sensorId);
However, this doesn’t seem to work reliably every time.

Once the error occurs, the sensor no longer works (even in the MagicLeap_Examples pixel sensor scene), and the only workaround I’ve found is rebooting the Magic Leap 2 device.

Is there any way to force a reset of a specific sensor to recover from this state without requiring a full reboot?

Give us as much detail as possible regarding the issue you’re experiencing:

Unity Editor version: 6000.0.38f1
ML2 OS version: 1.12.0
Unity SDK version: v2.6.0
Host OS: Windows 11 (23H2)

Error messages from logs

> 05-07 07:54:37.790 17790 17812 E Unity   : Error: XrCreatePixelSensor in the Magic Leap API failed. Reason: PixelSensorNotAvailableML 
> 05-07 07:54:37.790 17790 17812 E Unity   : UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
> 05-07 07:54:37.790 17790 17812 E Unity   : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
> 05-07 07:54:37.790 17790 17812 E Unity   : UnityEngine.Logger:LogFormat(LogType, String, Object[])
> 05-07 07:54:37.790 17790 17812 E Unity   : UnityEngine.Debug:LogErrorFormat(String, Object[])
> 05-07 07:54:37.790 17790 17812 E Unity   : UnityEngine.XR.MagicLeap.MLPluginLog:ErrorFormat(String, Object[]) (at .\Library\PackageCache\com.magicleap.unitysdk@99d11877b11e\Runtime\Common\Utils\MLPluginLog.cs:154)
> 05-07 07:54:37.790 17790 17812 E Unity   : MagicLeap.OpenXR.Utils:DidXrCallSucceed(XrResult, String, Predicate`1, Boolean) (at .\Library\PackageCache\com.magicleap.unitysdk@99d11877b11e\Runtime\OpenXR\OpenXRUtils.cs:104)
> 05-07 07:54:37.790 17790 17812 E Unity   : MagicLeap.OpenXR.Features.PixelSensors.PixelSensor:CreatePixelSensor() (at .\Library\PackageCache\com.magicleap.unitysdk@99d11877b11e\Runtime\OpenXR\PixelSensors\MagicLeapPixelSensor.cs:60)
> 05-07 07:54:37.790 17790 17812 E Unity   : MagicLeap.OpenXR.Features.PixelSensors.MagicLeapPixelSensorFeature:CreatePixelSensor(PixelSensorId) (at .\Library\PackageCache\com.magi
> 05-07 07:54:37.790 17790 17812 W Unity   : [1669] Failed to create the 'Depth Center' sensor. Status Undefined.
> 05-07 07:54:37.790 17790 17812 W Unity   : UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
> 05-07 07:54:37.790 17790 17812 W Unity   : UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
> 05-07 07:54:37.790 17790 17812 W Unity   : UnityEngine.Logger:Log(LogType, Object, Object)
> 05-07 07:54:37.790 17790 17812 W Unity   : UnityEngine.Debug:LogWarning(Object, Object)
> 05-07 07:54:37.790 17790 17812 W Unity   : AvatarMedical.<TryInitializeSensor>d__21:MoveNext() (at C:\Users\quent\Documents\ws\ScapulaOpenXR\Assets\Scripts\Recorder\CamerasRecorder.cs:238)
> 05-07 07:54:37.790 17790 17812 W Unity   : UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at \home\bokken\build\output\unity\unity\Runtime\Export\Scripting\Coroutines.cs:17)
1 Like

Do you try to get the status of the pixel sensor before creating it?

pixelSensor.GetSensorStatus(sensorId.Value)

Yes, it always remains in the Undefined state.

status = pixelSensorFeature.GetSensorStatus(sensorId);
Debug.Log($"[{Time.frameCount}] Creating the sensor '{sensorId}'... Status {status}.", context);
configure = pixelSensorFeature.CreatePixelSensor(sensorId);
if (configure)
{
    Debug.Log($"[{Time.frameCount}] The sensor '{sensorId}' has been created successfully.", context);
}
else
{
    Debug.LogWarning($"[{Time.frameCount}] Failed to create the '{sensorId}' sensor. Status {status}.", context);
}

This code works fine after a clean reboot, but if the application hasn’t shut down properly and the code to destroy the pixel isn’t called (for example, after an application crash), I can’t recover without rebooting the Magic Leap 2.

If necessary, I can try creating a minimal project that reproduces the problem.

Is there any update regarding this problem?

Unfortunately we do not have an update for this issue. It appears to be an issue with the OpenXR runtime which currently only allows one process to access the sensor at a time and is not reclaimed on the OS. Please note that the API is considered experimental at this time.

1 Like