Input System crashes Runtime on Application Close

We are getting Input System related crashes whenever we close the application. Anyone experienced something similar ? Looks like it wants to access an action thats no longer there ;). Unity 2022.3.45f1 , Input System Package 1.11.0

Bugreport ID: IN-94027

Are you sure for all the events you subscribe to, you unsubscribe?

I did. But we have lots of packages and a pretty big codebase, something may have slipped the net. I tried to dispose the input maps that we use but that is not working either. Is there a reccomended way to “shutdown” / dispose the internal state of the input system that i am not aware of?

well, with any luck you have some form of input manager, where all this is worked from, so you can just disabled it there ondisable/destory of that and/or disable it in your quit option. But because users love alt+f4, the disable/destroy should cover it

Those logs come right before the crash. Maybe someone knows where i need to look in order to find the issue.

Action count in old and new state must be the same
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:RestoreActionStatesAfterReResolvingBindings(UnmanagedMemory, InputControlList`1, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:541)
UnityEngine.InputSystem.InputActionState:FinishBindingResolution(Boolean, UnmanagedMemory, InputControlList`1, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:496)
UnityEngine.InputSystem.InputActionMap:ResolveBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionMap.cs:1391)
UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionMap.cs:1237)
UnityEngine.InputSystem.InputActionState:DeferredResolutionOfBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:4527)
UnityEngine.InputSystem.DeferBindingResolutionWrapper:Dispose() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionRebindingExtensions.cs:2813)
UnityEngine.InputSystem.PlayerInput:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\PlayerInput\PlayerInput.cs:1748)

Map count in old and new state must be the same
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:RestoreActionStatesAfterReResolvingBindings(UnmanagedMemory, InputControlList`1, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:542)
UnityEngine.InputSystem.InputActionState:FinishBindingResolution(Boolean, UnmanagedMemory, InputControlList`1, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:496)
UnityEngine.InputSystem.InputActionMap:ResolveBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionMap.cs:1391)
UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionMap.cs:1237)
UnityEngine.InputSystem.InputActionState:DeferredResolutionOfBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:4527)
UnityEngine.InputSystem.DeferBindingResolutionWrapper:Dispose() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionRebindingExtensions.cs:2813)
UnityEngine.InputSystem.PlayerInput:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\PlayerInput\PlayerInput.cs:1748)

Action map must be contained in state
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:FetchActionState(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:899)
UnityEngine.InputSystem.InputAction:get_currentState() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:1649)
UnityEngine.InputSystem.InputAction:get_phase() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:507)
UnityEngine.InputSystem.InputAction:get_enabled() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:532)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:931)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Action index is out of range
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:FetchActionState(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:900)
UnityEngine.InputSystem.InputAction:get_currentState() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:1649)
UnityEngine.InputSystem.InputAction:get_phase() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:507)
UnityEngine.InputSystem.InputAction:get_enabled() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:532)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:931)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Action map must be contained in state
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:DisableSingleAction(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1073)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:934)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Action map must be contained in state
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:DisableControls(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1086)
UnityEngine.InputSystem.InputActionState:DisableSingleAction(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1075)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:934)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Action index out of range when disabling controls
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:DisableControls(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1089)
UnityEngine.InputSystem.InputActionState:DisableSingleAction(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1075)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:934)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Map index out of range in DisableControls(InputAction)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Assert(Boolean, String)
UnityEngine.InputSystem.InputActionState:DisableControls(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1094)
UnityEngine.InputSystem.InputActionState:DisableSingleAction(InputAction) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputActionState.cs:1075)
UnityEngine.InputSystem.InputAction:Disable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Actions\InputAction.cs:934)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:TryDisableInputAction(InputActionReference, Boolean) (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:DisableAllActions() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1598)
UnityEngine.InputSystem.UI.InputSystemUIInputModule:OnDisable() (at .\Library\PackageCache\com.unity.inputsystem@1.11.0\InputSystem\Plugins\UI\InputSystemUIInputModule.cs:1549)

Crash!!!

Interestingly, this phrase appears a few times out there, and I found this Input system errors. Am I doing something wrong or is the input system broken? : r/Unity3D which mentions it seems to be caused by enable/disable of the input system, which we have all been lead to believe we need to do.

Now, as its not a problem Ive had myself, it seems odd, but I am wondering if it perhaps is caused by calling disable on it twice? hence when they removed it, it seemed to fix it, cos now its only done once…

Does it still occur if you remove the disables?

The Crash does not happen if i remove the ‘InputSystemUIInputModule’ from the build. It seems to be related to this module. In the Disable method of it, you can see that it tries to disable input actions that are no longer available.

OK, but thats not what I asked :stuck_out_tongue:

Yeah sorry - the linked thread does not lead to a solution. In general searching for hints on how to fix those errors/warnings leads into more deadends than anything helpful. I tried to disable everything that enables or diables Maps / Actions but that does not help either. However as i said i can clearly track this down to the OnDisbable() Method of the ‘InputSystemUIInputModule’. Since this one lives from game start till shutdown, there is no need for me to even have the functionality in the first place. So my hacky solution rn was to create a Script that inherits this class and overrides the OnDisable method. This seems to fix my crashes. But it is an ugly bandaid solution. Whatever the ‘user error’ on our side is - it would be nice if the application does not crash trying to access invalid memory but rather provide helpful information on the issue.

UPDATE: Switched from Input System 1.11.0 to 1.12.0 whicht results in a “Application not responding” message on quit. Same setup that worked in the prior build on 1.11.0 (skipping the OnDisable), nothing changed just the Input System was updated.

Id say log a bug. While Ive not had the same, see if you can make a smaller version of your senario that does the sam and log it as a bug.

(I will warn you though, they are amazingly good at not being able to recreate issues)