microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Clicking buttons on both controllers Crashes Unity #1344

Closed SimonDarksideJ closed 6 years ago

SimonDarksideJ commented 6 years ago

Overview

When using the MRTK (confirmed it's no an issue if done manually) using the button on one or the other controller is fine. However, if you click any button on either controller at the same time (doesn't have to be the same button), Unity crashes.

Expected Behavior

Unity shouldn't crash :D and you should be able to use both controllers buttons simultaneously

Actual Behavior

Unity crashes when buttons on both controllers are used at the same time.

Steps to reproduce

Using either the MRTK or the example scenes 1: Open scen 2: Add scene defaults 3: Run Scene 4: Click buttons at the same time on both controllers

Unity Editor Version

MRTP4

Mixed Reality Toolkit Release Version

Master

StephenHodgson commented 6 years ago

I wonder if this is a crash caused by the InteractionManager?

@DDReaper can you PM me the crash report?

SimonDarksideJ commented 6 years ago

I doubt it's the interaction manager, as I'm using that in other projects without issue, but happy to be proved wrong. I'll try and get it tomorrow, however, you should be able to easily recreate the crash yourself

StephenHodgson commented 6 years ago

Yeah, I'll def try to get the crash report when I get in tomorrow.

keveleigh commented 6 years ago

I looked into this very briefly yesterday and saw a message about a nullable object not having a value. I have a feeling this is somewhere in the Toolkit's InputManager.

StephenHodgson commented 6 years ago

Here's the errors from the editor just before the crash:

InvalidOperationException: Nullable object must have a value.
  at System.Nullable`1[System.Int32].get_Value () [0x0000b] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Nullable.cs:108 
  at HoloToolkit.Unity.InputModule.FocusManager.GetPointer (IPointingSource pointingSource) [0x0001d] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:790 
  at HoloToolkit.Unity.InputModule.FocusManager.GetPointingExtent (IPointingSource pointingSource) [0x00004] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:446 
  at HoloToolkit.Unity.InputModule.GazeManager.UpdateGazeInfo () [0x000ab] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Gaze\GazeManager.cs:206 
  at HoloToolkit.Unity.InputModule.GazeManager.OnPreRaycast () [0x00002] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Gaze\GazeManager.cs:220 
  at HoloToolkit.Unity.InputModule.FocusManager.UpdatePointer (HoloToolkit.Unity.InputModule.PointerData pointer) [0x00007] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:503 
  at HoloToolkit.Unity.InputModule.FocusManager.UpdatePointers () [0x000ef] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:491 
  at HoloToolkit.Unity.InputModule.FocusManager.Update () [0x00002] in C:\Valorem Projects\External\MixedRealityToolkit-Unity\Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:74 

(Filename: /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Nullable.cs Line: 108)

Assertion failed
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean)
HoloToolkit.Unity.InputModule.FocusManager:GetPointer(IPointingSource) (at Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:789)
HoloToolkit.Unity.InputModule.FocusManager:GetSpecificPointerEventData(IPointingSource) (at Assets\HoloToolkit\Input\Scripts\Focus\FocusManager.cs:441)
HoloToolkit.Unity.InputModule.InputManager:RaiseSourceUp(IInputSource, UInt32, InteractionSourcePressInfo, Object[]) (at Assets\HoloToolkit\Input\Scripts\Utilities\Managers\InputManager.cs:430)
HoloToolkit.Unity.InputModule.InteractionInputSource:InteractionManager_InteractionSourceReleased(InteractionSourceReleasedEventArgs) (at Assets\HoloToolkit\Input\Scripts\InputSources\InteractionInputSource.cs:919)
UnityEngine.XR.WSA.Input.InteractionManager:OnSourceEvent(EventType, InteractionSourceState, InteractionSourcePressType) (at C:\buildslave\unity\build\Runtime\VR\HoloLens\ScriptBindings\GestureSource.cs:481)

(Filename: Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs Line: 789)
StephenHodgson commented 6 years ago

I noticed that these errors also get raised after pressing any button by itself as well.

These errors appeared after #1332 was merged in, but the double controller press editor crashing was def introduced in #1256.

Possible causes:

SimonDarksideJ commented 6 years ago

Glad you managed to find the source :D I did note the double click crash in #1256 although it seems to have been missed

StephenHodgson commented 6 years ago

I think it's definitely because we're switching pointers and the pointer index is briefly empty. image

Might be some kind of race condition there.

SimonDarksideJ commented 6 years ago

I was curious about that behaviour. Is there any reason the pointers cannot be handled independently, why does it need a "Master", why not both (or all, including Gaze)?

StephenHodgson commented 6 years ago

Yeah, I'm trying to figure out why we're even unregistering the pointer when we switch. Cause that's really what the problem is, bc all the pointers need to be indexed during the update in the Focus Manager. I think we should only unregister the pointer on source lost. @keveleigh thoughts?

StephenHodgson commented 6 years ago

I got a fix

rickasheye commented 6 years ago

this is pretty much what happened

rickasheye commented 6 years ago

that is the problem I tried it and it crashed

Abstiens commented 6 years ago

I am not sure if my problem is related to this one.

For me, the crash happens, after i release the Trigger on the backside of the controller (no message, Unity just disappears). Nothing happens, while i click and hold the trigger. If i pause Unity while i hold the trigger and then release it, it crashes immediatly after i resume.

I am using MRTP4 and the latest master branch. I also tried Pull Request #1350 (applied as patch), but same result.

StephenHodgson commented 6 years ago

Probably related in some way, but I'd still like you to open a separate issue for this detailing your repro steps please.

Abstiens commented 6 years ago

Wow, you are really fast. Thank you in advance!

1363