WEKIT-ECS / MIRAGE-XR

MirageXR is a reference implementation of an XR training system. MirageXR enables experts and learners to share experience via XR and wearables using ghost tracks, realtime feedback, and anchored instruction.
Other
28 stars 5 forks source link

Error Message / Exception During Asset Import and During Runtime "ArgumentException: An item with the same key has already been added. Key: <HoloLensHand>" #2158

Open BenediktHensen opened 2 days ago

BenediktHensen commented 2 days ago

Whenever the assets of the project are loaded and during runtime when initializing OpenXR, the following error message/exception is thrown:

ArgumentException: An item with the same key has already been added. Key: <HoloLensHand>
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <da017b879d2f49589e8a5d373b2b6da4>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <da017b879d2f49589e8a5d373b2b6da4>:0)
UnityEngine.XR.OpenXR.Features.OpenXRInteractionFeature.RegisterLayouts () (at ./Library/PackageCache/com.unity.xr.openxr@1.12.0/Runtime/Features/OpenXRInteractionFeature.cs:313)
UnityEngine.XR.OpenXR.Input.OpenXRInput.RegisterLayouts () (at ./Library/PackageCache/com.unity.xr.openxr@1.12.0/Runtime/input/OpenXRInput.cs:156)
UnityEngine.XR.OpenXR.OpenXRLoaderBase.InitializeInternal () (at ./Library/PackageCache/com.unity.xr.openxr@1.12.0/Runtime/OpenXRLoader.cs:211)
UnityEngine.XR.OpenXR.OpenXRLoaderBase.Initialize () (at ./Library/PackageCache/com.unity.xr.openxr@1.12.0/Runtime/OpenXRLoader.cs:185)
UnityEngine.XR.Management.XRGeneralSettings:AttemptInitializeXRSDKOnLoad() (at ./Library/PackageCache/com.unity.xr.management@4.5.0/Runtime/XRGeneralSettings.cs:148)

It seems that there is an error in the XR configuration for the Microsoft HoloLens. It could be a corrupted config file or a conflict between the subsystems of the MRTK and the OpenXR runtime.

BenediktHensen commented 2 days ago

I investigated this some more and created an output log for each feature set that is called in the function.

The exception happens because it first gets the following data and populates it in a dictionary with the enabled interaction profiles:

Profile Type: XRController Device Layout Name: <HoloLensHand> Feature: MicrosoftHandInteraction Standalone (UnityEngine.XR.OpenXR.Features.Interactions.MicrosoftHandInteraction)

Next, it gets the following data:

Profile Type: XRController Device Layout Name: <HoloLensHand> Feature: MicrosoftHandInteractionLegacy Standalone (Microsoft.MixedReality.OpenXR.MicrosoftHandInteractionLegacy)

Since both target the HoloLensHand feature, this causes an exception as this key already exists in the dictionary.

This happens altough the interaction profiles are not enabled. There is also a bunch of other interaction profiles that get loaded such as HPReverbG2Controller, ViveController, DPad, etc. which we did not activate or use. But since there is only one provider for each, these cause no errors.

The Open XR Package settings file seems to be broken. If I save the entire Unity project via File > Save Project, I also get a warning

Importer(NativeFormatImporter) generated inconsistent result for asset(guid:b3a3cc9ae17858f4a9346913737e2188) "Assets/XR/Settings/Open XR Package Settings.asset"
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets (string[],string[],string[],string[],string[],bool)

In the folder Assets/XR/Settings, there is a file called OpenXR Package settings.asset and Open Xr Package Settings.asset, with a space and without. It seems like Unity cannot read one of them properly and then just activates all interaction providers as a fallback.