ultraleap / UnityPlugin

Ultraleap SDK for Unity.
https://docs.ultraleap.com/unity-api/
Apache License 2.0
531 stars 168 forks source link

KeyNotFoundException: The given key 'Left HardContactHand (Leap.Unity.PhysicalHands.HardContactHand)' was not present in the dictionary. #1634

Closed vincentsys closed 3 months ago

vincentsys commented 5 months ago

Hi, I have encountered following incident which occurs infrequently while using ultraleap hand tracking. It leads to a crash of the app. It sometimes occurs with the Left HardContactHand and sometimes with the Right HardContactHand.

The error message is following:

KeyNotFoundException: The given key 'Left HardContactHand (Leap.Unity.PhysicalHands.HardContactHand)' was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <834b2ded5dad441e8c7a4287897d63c7>:0)
Leap.Unity.PhysicalHands.GrabHelperObject.SetBoneGrabbing (Leap.Unity.PhysicalHands.ContactHand hand, System.Boolean add) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs:845)
Leap.Unity.PhysicalHands.GrabHelperObject.UpdateGrabbingValues () (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs:821)
Leap.Unity.PhysicalHands.GrabHelperObject.UpdateHelper () (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/Helpers/GrabHelperObject.cs:357)
Leap.Unity.PhysicalHands.GrabHelper.UpdateHelpers () (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/Helpers/GrabHelper.cs:223)
Leap.Unity.PhysicalHands.GrabHelper.OnFixedFrame (Leap.Frame frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/Helpers/GrabHelper.cs:89)
Leap.Unity.LeapProvider.DispatchFixedFrameEvent (Leap.Frame frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/LeapProvider.cs:79)
Leap.Unity.PhysicalHands.PhysicalHandsManager.ProcessFrame (Leap.Frame inputFrame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Physical Hands/Runtime/Scripts/PhysicalHandsManager.cs:263)
Leap.Unity.LeapProvider.DispatchFixedFrameEvent (Leap.Frame frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/LeapProvider.cs:79)
Leap.Unity.PostProcessProvider.processFixedFrame (Leap.Frame inputFrame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/PostProcessProvider.cs:177)
Leap.Unity.LeapProvider.DispatchFixedFrameEvent (Leap.Frame frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/LeapProvider.cs:79)
Leap.Unity.XRLeapProviderManager.HandleFixedFrame (Leap.Frame _frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/XRLeapProviderManager.cs:194)
Leap.Unity.LeapProvider.DispatchFixedFrameEvent (Leap.Frame frame) (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/Core/Runtime/Scripts/LeapProvider.cs:79)
Ultraleap.Tracking.OpenXR.OpenXRLeapProvider.FixedUpdate () (at ./Library/PackageCache/com.ultraleap.tracking@6.15.0/OpenXR/Runtime/Scripts/OpenXRLeapProvider.cs:131)

Would it be possible to check whether the key exists in the dictionary before accessing it?

MattGrayUL commented 5 months ago

Can I just check which version of the Plugin you are using? (or which branch, if not using a released version)

vincentsys commented 5 months ago

I'm using version 6.15.0 and the release branch

MattGrayUL commented 5 months ago

Thanks - we are currently working on a new major release of the Plugin (7.0.0) which makes some optimizations to the Psychical Hands. We will make sure that if still necessary, we also check for existence of this key before using it :)

vincentsys commented 5 months ago

Thank you :)