Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug IndexOutOfRangeException when changing to an ActionMap where a GamePad binding is set

Discussion in 'Input System' started by Fira-Soft, Feb 22, 2023.

  1. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    I'm having a issue with the new input system.

    In an .inputasset asset, I have my maps and actions set. But when disabling a map and enabling another I'm receiving the erros (5 erros in total) added on the end of this post.

    They are all triggered after the
    matikaInputActionsAsset.matikaInputActions.Dialogue.Enable()


    This is done after the game is running and I change maps because player is entering a dialogue.
    I was able to pin point the error to when the newly enabled map has a Binding with a path to a Gamepad button, this error occurs, when I remove this Binding from the action, the error doesn't show up.

    I tried to reproduce it on a small project but wasn't able to reproduce the error.

    I'm using a ScriptableObject that has a instance of the generated InputActionAsset, and using it whenever a system need access to it. I dont think this has any relation with the issue.

    From what I understand, the out of range exceptions has something to do with the number of each ActionMap (like iterating on the wrong map). Could also be related to the number of the Actions or the number of bindings, but only really happens when there is a binding to a Gamepad button (button west on my case). (I'm always using the keyboard binding to reproduce the erro)

    I can run tests and answer question to help pinpoint the issue since this is 100% reproducible, and with some direction we might be able to create a small project with the problem.

    I'm using a Input Asset 1.5.0 ( also happens on 1.3.0) and Unity 2021.1.28f1

    I thought i could have something to do with the fix on 1.4.0 (Fixed IndexOutOfRangeException when having multiple interactions on an action and/or binding in an action map other than the first of an asset (case 1392559).) but after updating to 1.5.0, the issue remained.

    Any suggestions?

    Code (CSharp):
    1.  matikaInputActionsAsset.matikaInputActions.PlayerControls.Disable();
    2.             matikaInputActionsAsset.matikaInputActions.Dialogue.Enable();
    3.             matikaInputActionsAsset.matikaInputActions.Map.Disable();

    Code (CSharp):
    1. Assertion failed
    2. UnityEngine.InputSystem.InputActionMap:Enable ()
    3.  
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. UnityEngine.InputSystem.InputManager.AddStateChangeMonitor (UnityEngine.InputSystem.InputControl control, UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor monitor, System.Int64 monitorIndex, System.UInt32 groupIndex) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/InputManagerStateMonitors.cs:35)
    3. UnityEngine.InputSystem.InputActionState.EnableControls (System.Int32 mapIndex, System.Int32 controlStartIndex, System.Int32 numControls) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionState.cs:1134)
    4. UnityEngine.InputSystem.InputActionState.EnableControls (UnityEngine.InputSystem.InputActionMap map) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionState.cs:947)
    5. UnityEngine.InputSystem.InputActionState.EnableAllActions (UnityEngine.InputSystem.InputActionMap map) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionState.cs:907)
    6. UnityEngine.InputSystem.InputActionMap.Enable () (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionMap.cs:541)
    7. MatikaInputActions+DialogueActions.Enable () (at Assets/Settings/Input Actions/MatikaInputActions.cs:1761)
    Code (CSharp):
    1. Control index out of range
    2. UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
    3. UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
    Code (CSharp):
    1. Exception 'ArgumentNullException' thrown from state change monitor 'InputActionState' on 'Key:/Keyboard/f'
    2. UnityEngine.InputSystem.LowLevel.NativeInputRuntime/<>c__DisplayClass7_0:<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
    3. UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
    Code (CSharp):
    1. ArgumentNullException: Value cannot be null.
    2. Parameter name: control
    3. UnityEngine.InputSystem.InputControlExtensions.CheckStateIsAtDefault (UnityEngine.InputSystem.InputControl control) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Controls/InputControlExtensions.cs:498)
    4. UnityEngine.InputSystem.InputActionState.ProcessControlStateChange (System.Int32 mapIndex, System.Int32 controlIndex, System.Int32 bindingIndex, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionState.cs:1448)
    5. UnityEngine.InputSystem.InputActionState.UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged (UnityEngine.InputSystem.InputControl control, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr, System.Int64 mapControlAndBindingIndex) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/Actions/InputActionState.cs:1326)
    6. UnityEngine.InputSystem.InputManager.FireStateChangeNotifications (System.Int32 deviceIndex, System.Double internalTime, UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr) (at Library/PackageCache/com.unity.inputsystem@1.5.0/InputSystem/InputManagerStateMonitors.cs:380)
    7. UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
    8. UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr)
    9.  
     
  2. CenkPaintbucket

    CenkPaintbucket

    Joined:
    Aug 3, 2022
    Posts:
    3
    I'm having the exact same problem - could you find a solution?