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

Gestures do not work on HL2 with OpenXR or XR SDK (but in the Unity Editor Player)

Open atiemark opened this issue 5 years ago • 13 comments

Describe the bug

I cannot get Gestures to work on the Hololens 2 using either the 'DefaultOpenXRInputSystemProfile' or DefaultXRSDKInputSystemProfile'. They do work in the Unity Editor in Play mode.

I assume this is related to #9380 and #7271 for the XR SDK ? Are Gestures currently supposed to work with OpenXR / the DefaultOpenXRInputSystemProfile?

Is there any way I can get Gestures to work on the Hololens 2 with my current MRTK and Unity Version or do I have to downgrade to Unity 2019.4, as mentioned here: https://github.com/microsoft/MixedRealityToolkit-Unity/issues/7271#issuecomment-737202451

My Gesture Manager class:

using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Input;
using UnityEngine;

public class AetherClickManager : InputSystemGlobalHandlerListener, IMixedRealityGestureHandler
{
   public void OnGestureCanceled(InputEventData eventData)
   {
       //throw new System.NotImplementedException();
   }

   public void OnGestureCompleted(InputEventData eventData)
   {
       foreach(var ptr in eventData.InputSource.Pointers)
       {
           if(ptr.Result.CurrentPointerTarget == null)
           {
               ApplicationManager.Broadcast(ApplicationManager.Signal.SignalAetherClicked);
               eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
           }
       }
   }

   public void OnGestureStarted(InputEventData eventData)
   {
       //throw new System.NotImplementedException();
   }

   public void OnGestureUpdated(InputEventData eventData)
   {
       //throw new System.NotImplementedException();
   }

   protected override void RegisterHandlers()
   {
       CoreServices.InputSystem?.RegisterHandler<IMixedRealityGestureHandler>(this);
   }

   protected override void UnregisterHandlers()
   {
       CoreServices.InputSystem?.UnregisterHandler<IMixedRealityGestureHandler>(this);
   }
}

To reproduce

Steps to reproduce the behavior:

  1. Implement InputSystemGlobalHandlerListener, IMixedRealityGestureHandler
  2. Build using either 'DefaultOpenXRInputSystemProfile' or DefaultXRSDKInputSystemProfile' and Run on Hololens 2
  3. No Gesture Handler function is called

Expected behavior

OnGestureCompleted(InputEventData eventData) should be called

Your setup (please complete the following information)

  • Unity Version 2020.2.2f1
  • MRTK Version 2.6.1

Target platform (please complete the following information)

  • HoloLens 2

atiemark avatar Mar 12 '21 16:03 atiemark

Are Gestures currently supposed to work with OpenXR / the DefaultOpenXRInputSystemProfile?

Currently, no. We're going through planning now to see how to best support them, since the APIs have changed a bit.

keveleigh avatar Mar 12 '21 17:03 keveleigh

Allright, thank you - So an option to work with Gestures on HL2 right now is to downgrade to Unity 2019.4, as mentioned here: https://github.com/microsoft/MixedRealityToolkit-Unity/issues/7271#issuecomment-737202451

Is this info still up-to-date?

atiemark avatar Mar 13 '21 09:03 atiemark

Correct. The legacy XR pipeline is currently the only one that supports gestures (which is the one that's been removed in 2020).

keveleigh avatar Mar 15 '21 17:03 keveleigh

I downgraded to Unity 2019.4.20f1, updated to MRTK 2.6.1 and still have the same issue as above. Gestures work in the Unity Editor but not when building and running on the HoloLens 2. I am using the DefaultXRSDKInputSystemProfile.

What am I missing? Do I have to use a different version of the MRTK or a different ConfigProfile? Thanks.

atiemark avatar Mar 15 '21 23:03 atiemark

Yeah, if you're using DefaultXRSDKInputSystemProfile that means you've updated to XR SDK. Gestures only works on legacy XR at the moment, so you'll want to use the DefaultMixedRealityToolkitConfigurationProfile and ensure you've set up XR via the old Player Settings -> UWP -> XR Settings (as opposed to XR Plugin Management)

keveleigh avatar Mar 15 '21 23:03 keveleigh

Thanks. Unfortunately I have encountered further problems:

When switching to Legacy XR and using the DefaultMixedRealityToolkitConfigurationProfile as mentioned, I receive the following errors in the console, seemingly related to the MRTK Input module:

NullReferenceException: Object reference not set to an instance of an object
Microsoft.MixedReality.Toolkit.WindowsMixedReality.Input.WindowsMixedRealityDeviceManager.Enable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Providers/WindowsMixedReality/XR2018/WindowsMixedRealityDeviceManager.cs:362)
Microsoft.MixedReality.Toolkit.BaseDataProviderAccessCoreSystem.Enable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/BaseDataProviderAccessCoreSystem.cs:36)
Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem.Enable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Services/InputSystem/MixedRealityInputSystem.cs:254)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit+<>c.<EnableAllServices>b__70_0 (Microsoft.MixedReality.Toolkit.IMixedRealityService service) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:1044)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.ExecuteOnAllServicesInOrder (System.Action`1[T] execute) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:1145)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.EnableAllServices () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:1044)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit.OnEnable () (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:711)

and:

Microsoft.MixedReality.Toolkit.Input.InputRecordingService has not set a value for IsEnabled, returning false.
UnityEngine.Debug:Assert(Boolean, String)
Microsoft.MixedReality.Toolkit.BaseService:get_IsEnabled() (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/BaseService.cs:90)
Microsoft.MixedReality.Toolkit.Input.InputRecordingService:LateUpdate() (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Providers/InputAnimation/InputRecordingService.cs:213)
Microsoft.MixedReality.Toolkit.BaseDataProviderAccessCoreSystem:LateUpdate() (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/BaseDataProviderAccessCoreSystem.cs:67)
Microsoft.MixedReality.Toolkit.Input.MixedRealityInputSystem:LateUpdate() (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Services/InputSystem/MixedRealityInputSystem.cs:271)
Microsoft.MixedReality.Toolkit.<>c:<LateUpdateAllServices>b__74_0(IMixedRealityService) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:1071)
Microsoft.MixedReality.Toolkit.MixedRealityToolkit:ExecuteOnAllServicesInOrder(Action`1) (at Library/PackageCache/com.microsoft.mixedreality.toolkit.foundation@e0ba9d7d5631-1615558949717/Core/Services/MixedRealityToolkit.cs:1145)

The latter disappears when setting the Input Simulation Service Type to 'None' in a cloned InputSystem Profile.

The app still works and runs as expected in the Unity Editor Player. Upon building and then running it on the Hololens 2 however, I receive the following error and exception. The app then does not start on the HL2 / the display stays blank:

image

probably related or the same as: https://github.com/microsoft/MixedReality-WebRTC/issues/553 ?

Any help would be really appreciated as I am facing a deadline. Maybe I should open a new issue for this?

atiemark avatar Mar 16 '21 16:03 atiemark

Huh, line 362 looks like https://github.com/microsoft/MixedRealityToolkit-Unity/blob/5a8213569f43221c3caad6bafebd0d210021f32d/Assets/MRTK/Providers/WindowsMixedReality/XR2018/WindowsMixedRealityDeviceManager.cs#L362

Do you have the Mixed Reality Input package installed? If so, can you try uninstalling?

keveleigh avatar Mar 16 '21 17:03 keveleigh

Yes, thank you - I had it installed, uninstalling it fixed the console errors.

I turned on Copy References, PDB files, Development Build and Deep Profiling Support and it seems like the exception has something to do with WindowsMRXRSDK.dll ?

image

atiemark avatar Mar 16 '21 20:03 atiemark

Yes, thank you - I had it installed, uninstalling it fixed the console errors.

I turned on Copy References, PDB files, Development Build and Deep Profiling Support and it seems like the exception has something to do with WindowsMRXRSDK.dll ?

image

updated my comment

atiemark avatar Mar 16 '21 21:03 atiemark

Do you have Windows XR Plugin installed?

keveleigh avatar Mar 16 '21 22:03 keveleigh

No. Here is a screenshot of my package manager. I assumed I need the "Windows Mixed Reality" Package which is deprecated and the Legacy XR Input Helpers? Thanks

image

Without the "Windows Mixed Reality" Package I get this exception:

[0,737682 / 38,152628] - AppCallbacks::Load
[27,430359 / 38,153714] - Starting first scene loading
The following GlobalManagers were stripped from the build (Either because they're not used or not supported on this platform):
  ClusterInputManager
Trying to initialize spatial input, but found no spatial interaction manager! This is catastrophic for a lot of input. 
(Filename: C:\buildslave\unity\build\Modules/VR/HoloLens/Gestures/GestureSource.cpp Line: 181)

Assertion failed on expression: 'NULL != this->ptr' 
(Filename: C:\buildslave\unity\build\PlatformDependent/Win/ComPtr.h Line: 87)

CORTEXPLORER HoloDeck.exe has triggered a breakpoint.

atiemark avatar Mar 17 '21 10:03 atiemark

@atiemark Update! I just opened #9843 for MRTK 2.7 which will add gesture support when running on OpenXR

keveleigh avatar May 20 '21 18:05 keveleigh

Fixed for OpenXR via #9843

keveleigh avatar May 21 '21 17:05 keveleigh