MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Hand Artifacts Remain In Scene When Using XR SDK on HoloLens 2

Open Holo-Fiedel opened this issue 5 years ago • 12 comments

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" 20210205_175404_HoloLens_2_XRSDK_Hand_Duplication_And_Artifacts

To reproduce

Steps to reproduce the behavior:

  1. Start a new Unity project (Unity 2019.4.19f1)
  2. Import MRTK v2.5.4 Foundation (I used the Unity Package from the Releases section, not the UPM)
  3. Hit apply on the MRTK project configuration window
  4. Click on the Unity Menu "Mixed Reality Toolkit --> Add to Scene and Configure..."
  5. In Project Settings install the XR Plugin Management
  6. Enable Windows Mixed Reality and "Initialize XR on Startup"
  7. Select the Windows Mixed Reality XR Settings and enable Depth Buffer Sharing (Depth 16bit) as well as Use Primary Window
  8. Leave Holographic Remoting off
  9. Add a Cube at a comfortable distance (to make sure you are in the app, when it starts)
  10. Build and deploy (I reproduced this behaviour in Master and Release build configuration)
  11. Start the app
  12. 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.

Holo-Fiedel avatar Feb 05 '21 17:02 Holo-Fiedel

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 

Holo-Fiedel avatar Feb 06 '21 11:02 Holo-Fiedel

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. 

Holo-Fiedel avatar Feb 08 '21 16:02 Holo-Fiedel

Apparently, this issue is related to / a possible duplication of #9165

Holo-Fiedel avatar Feb 11 '21 07:02 Holo-Fiedel

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.

Holo-Fiedel avatar Feb 25 '21 15:02 Holo-Fiedel

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.

CuriousNewt avatar Feb 26 '21 13:02 CuriousNewt

Thank you for the detailed report @Holo-Fiedel!

Does this also occur if you disable displaying the hand mesh?

david-c-kline avatar Feb 26 '21 19:02 david-c-kline

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.

ModischFabrications avatar Mar 08 '21 11:03 ModischFabrications

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.

Holo-Fiedel avatar Mar 08 '21 11:03 Holo-Fiedel

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.

Holo-Fiedel avatar Mar 08 '21 13:03 Holo-Fiedel

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.

ModischFabrications avatar Mar 08 '21 20:03 ModischFabrications

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

image

soshogoh avatar May 06 '21 12:05 soshogoh

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.

keveleigh avatar May 26 '21 23:05 keveleigh