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

**URL:** https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668
**Category:** Unity Development
**Tags:** development, unity, bug
**Created:** [May 7, 2025, 9:46am UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668 "2025-05-07T09:46:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![quentin.petit](https://avatars.discourse-cdn.com/v4/letter/q/839c29/32.png) [@quentin.petit](https://forum.magicleap.cloud/u/quentin.petit)
#### Post date: [May 7, 2025, 9:46am UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668/1 "2025-05-07T09:46:25Z")

</div>

Hello,

 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/5/5e34a1898113e15604d67011a46143f5bf99da86.jpeg)

```auto
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**

```auto
> 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)

```

---

<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: [May 7, 2025, 7:25pm UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668/2 "2025-05-07T19:25:17Z")

</div>

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

pixelSensor.GetSensorStatus(sensorId.Value)

---

<div class="post-metadata">

### Author: ![quentin.petit](https://avatars.discourse-cdn.com/v4/letter/q/839c29/32.png) [@quentin.petit](https://forum.magicleap.cloud/u/quentin.petit)
#### Post date: [May 8, 2025, 3:08pm UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668/3 "2025-05-08T15:08:48Z")

</div>

Yes, it always remains in the **Undefined** state.

> [@quentin.petit](#):
>
> `> 05-07 07:54:37.790 17790 17812 W Unity : [1669] Failed to create the 'Depth Center' sensor. Status Undefined.`

```auto
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.

---

<div class="post-metadata">

### Author: ![quentin.petit](https://avatars.discourse-cdn.com/v4/letter/q/839c29/32.png) [@quentin.petit](https://forum.magicleap.cloud/u/quentin.petit)
#### Post date: [June 3, 2025, 12:45pm UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668/4 "2025-06-03T12:45:11Z")

</div>

Is there any update regarding this problem?

---

<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: [June 3, 2025, 10:19pm UTC](https://forum.magicleap.cloud/t/error-xrcreatepixelsensor-in-the-magic-leap-api-failed-reason-pixelsensornotavailableml/5668/5 "2025-06-03T22:19:21Z")

</div>

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.
