Hand Artifacts Remain In Scene When Using XR SDK on HoloLens 2
Description
When using XR SDK on HoloLens 2 with the default configurations, hands, their bone visualization and their meshes appear to not be cleaned up correctly:
- Hand bone visualizations remain in the scene (their poses suggest this happens when the HoloLens loses their tracking)
- Their hand rays remain visible as well
- The according hand meshes however seem to be still overlayed correctly with the hand. This leads to the meshes stacking with the ones of the newly found hands multiplying their color to a bright white
Please refer to the attached screenshot "20210205_175404_HoloLens_2_XRSDK_Hand_Duplication_And_Artifacts.jpg"

To reproduce
Steps to reproduce the behavior:
- Start a new Unity project (Unity 2019.4.19f1)
- Import MRTK v2.5.4 Foundation (I used the Unity Package from the Releases section, not the UPM)
- Hit apply on the MRTK project configuration window
- Click on the Unity Menu "Mixed Reality Toolkit --> Add to Scene and Configure..."
- In Project Settings install the XR Plugin Management
- Enable Windows Mixed Reality and "Initialize XR on Startup"
- Select the Windows Mixed Reality XR Settings and enable Depth Buffer Sharing (Depth 16bit) as well as Use Primary Window
- Leave Holographic Remoting off
- Add a Cube at a comfortable distance (to make sure you are in the app, when it starts)
- Build and deploy (I reproduced this behaviour in Master and Release build configuration)
- Start the app
- Interact with your hands, having them be found and lost several times by Hand Tracking --> Observe that in some occasions, the hand bone visualization as well as the ray remain in the scene, when a hand is lost --> Observe that every time this happens, the according mesh is still following the hand tracking, now overlaying with the new hand mesh
Expected behavior
When a(n articulated) hand is lost, its bone visualizaton, hand ray and mesh should be cleaned up and not remain in the scene
Setup
- Unity Version 2019.4.19f1
- MRTK Version 2.5.4
Target platform
- HoloLens 2
Additional Information
I tested MRTK v2.5.3 as well and while the bug did reproduce in that version, it happened with less frequency.
Here is the UnityPlayer.log file from the session in which I took the screenshot: UnityPlayer_HoloLens_2_XRSDK_Hand_Duplication_And_Artifacts.log
There are ArgumentException's coming from UpdateHandMesh, probably related to the problem
ArgumentException: Value does not fall within the expected range.
at Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityHandMeshProvider.UpdateHandMesh (Windows.UI.Input.Spatial.SpatialInteractionSourceState sourceState) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityXRSDKArticulatedHand.UpdateHandData (UnityEngine.XR.InputDevice inputDevice) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityXRSDKArticulatedHand.UpdateController (UnityEngine.XR.InputDevice inputDevice) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.Input.XRSDKDeviceManager.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityDeviceManager.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.BaseDataProviderAccessCoreSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit+<>c.<UpdateAllServices>b__67_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService service) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesInOrder (System.Action`1[T] execute) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UpdateAllServices () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.Update () [0x00000] in <00000000000000000000000000000000>:0
In a different session, the log reads:
ArgumentException: Value does not fall within the expected range.
at Windows.Perception.People.HandMeshObserver.GetVertexStateForPose (Windows.Perception.People.HandPose handPose) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.WindowsMixedReality.WindowsMixedRealityHandMeshProvider.UpdateHandMesh (Windows.UI.Input.Spatial.SpatialInteractionSourceState sourceState) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityXRSDKArticulatedHand.UpdateHandData (UnityEngine.XR.InputDevice inputDevice) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityXRSDKArticulatedHand.UpdateController (UnityEngine.XR.InputDevice inputDevice) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.Input.XRSDKDeviceManager.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.XRSDK.WindowsMixedReality.WindowsMixedRealityDeviceManager.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.BaseDataProviderAccessCoreSystem.Update () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit+<>c.<UpdateAllServices>b__67_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService service) [0x00000] in <00000000000000000000000000000000>:0
at System.Action`1[T].Invoke (T obj) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesInOrder (System.Action`1[T] execute) [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.UpdateAllServices () [0x00000] in <00000000000000000000000000000000>:0
at Microsoft.MixedReality.Toolkit.MixedRealityToolkit.Update () [0x00000] in <00000000000000000000000000000000>:0
followed by
[XRInputSubsystem] A device disconnection with the id 2000006732 has been reported but no device with that id was connected.
Apparently, this issue is related to / a possible duplication of #9165
A (sub-optimal) way to mitigate the effects of this phenomenon seems to be to try-catch the UpdateController call in the XRSDKDeviceManager.Update() method like this (l. 93 , ff.):
if (controller != null && lastInputDevices.Contains(device))
{
try
{
controller.UpdateController(device);
}
catch (Exception exception)
{
Debug.Log($"UpdateController({device}) failed");
}
finally
{
lastInputDevices.Remove(device);
}
}
This way, if UpdateController fails, as indicated by the exception stack trace in the previous comments, the according device is removed.
Depending on your use case, you can use OpenXR to solve the issue. You'd need to upgrade your Unity project to Unity2020.**** in order to enable OpenXR for MRTK. This solved my issue with hands, however my app is dependent on QR tracking, which cannot be accessed through MRTK when using OpenXR.
Thank you for the detailed report @Holo-Fiedel!
Does this also occur if you disable displaying the hand mesh?
try-catch
Do you have a hint on how do fix it when imported as a unity package @Holo-Fiedel ? Direct changes to this file are discarded on reload, but I fear that waiting for a proper fix might take too long.
Do you have a hint on how do fix it when imported as a unity package @Holo-Fiedel ? Direct changes to this file are discarded on reload, but I fear that waiting for a proper fix might take too long.
Unfortunately, I have not. In our investigations into the issue it became clear, that the XRSDKDeviceManager is supposed to handle the cleanup internally.
This issue also prevents us from consuming the MRTK via UPM.
Does this also occur if you disable displaying the hand mesh?
@davidkline-ms, I haven't been able to reproduce the behaviour when disabling the hand mesh visualization.
As the logs above indicate, this issue might come from handMeshObserver.GetVertexStateForPose(handPose)
When disabling the Hand Mesh Visualization in the profile, WindowsMixedRealityHandMeshProvider.UpdateHandMesh returns before reaching the call of the HandMeshObserver.
QR tracking, which cannot be accessed through MRTK when using OpenXR
Oh wow, I wish I had read that earlier before porting everything to OpenXR. Definitely stuck between a rock and a hard place then.
Hi MRTK team, I also got the same problem from our customer. The following problems occurred in Hololens2 application using MRTK. Hand lost detection may not be performed correctly, and hand mesh / joint objects may continue to remain in the space. As a result, the UI that follows the detected hand will follow the object of the hand that remains in space(Please see the image snapshot: red rectangle highlighted).
Could you please comment on how to delete the remained hand mesh/joint object?
・Unity:2019.4.15f1 ・MRTK:2.5.9 ・XR Plugin Management:3.2.16

The stuck hand tracking should be fixed via #9890 in the upcoming 2.7.0 release. Thanks for the investigation here, and please re-open if you're still able to repro on 2.7.0.