Update to 1.1.1 - multi-binding Actions no longer working

I updated from Input System 1.1.0-preview.5 to 1.1.1 (I also tried 1.1.0-pre.6 with the same result as 1.1.1) and I seem to have a non-functional input system now. I can roll back to 1.1.0-pre.5 and everything starts working correctly again. Back to 1.1.1 and (even after a Unity restart) it’s broken.

All of my existing Input Actions that had multiple bindings on them seem either inert (don’t produce any changing values when I move pedals, joystick, gamepad analog paddles, etc), or only output a fixed value of around 0.501 (not exactly 0.5). After removing all other bindings except for keyboard bindings, these Input Actions now only show a ReadValue of 0.0 regardless of keyboard state. Usually the value jumps to 1.0 when I hit the bound key.

Additionally, when I try to open the Input Debug window (under Analysis), sometimes I get the following error over-and-over at high speed:

ArgumentNullException: Value cannot be null.
Parameter name: layoutName
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/EditorInputControlLayoutCache.cs:151)
UnityEngine.InputSystem.Editor.EditorInputControlLayoutCache.GetIconForLayout (System.String layoutName) (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/EditorInputControlLayoutCache.cs:176)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.AddControlLayoutItem (UnityEngine.InputSystem.Layouts.InputControlLayout layout, UnityEditor.IMGUI.Controls.TreeViewItem parent, System.Int32& id) (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:755)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.AddControlLayouts (UnityEditor.IMGUI.Controls.TreeViewItem parent, System.Int32& id) (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:717)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView.BuildRoot () (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:586)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.FetchData () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.IMGUI.Controls.TreeViewDataSource.ReloadData () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.IMGUI.Controls.TreeView+TreeViewControlDataSource.ReloadData () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.IMGUI.Controls.TreeViewController.ReloadData () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.IMGUI.Controls.TreeView.Reload () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEngine.InputSystem.Editor.InputDebuggerWindow+InputSystemTreeView..ctor (UnityEditor.IMGUI.Controls.TreeViewState state) (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:407)
UnityEngine.InputSystem.Editor.InputDebuggerWindow.Initialize () (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:167)
UnityEngine.InputSystem.Editor.InputDebuggerWindow.OnGUI () (at Library/PackageCache/com.unity.inputsystem@1.1.1/InputSystem/Editor/Debugger/InputDebuggerWindow.cs:197)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEditor.DockArea.OldOnGUI () (at <8d21067e8d9c494db25a2b2485216e63>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <fe7ee1881b524b0d9443f74417fb598b>:0)

At this point I’m not really sure how to go about resolving this.

My project is a Unity 2019.4 project. I created a brand new project with Unity 2021.1 and imported Input System 1.1.1 into it, and set up some similar Input Actions with multiple bindings, and they seem to work correctly, but unfortunately I am not in a position to upgrade my main project away from 2019.4.

Should I expect Input System 1.1.1 to work with Unity 2019.4 or have I jumped the gun on this?

1 Like

I’ve created a fresh, new Input Action as a SerializedField on one of my components, set it to Value/Any, and bound a keyboard button to it with no Interactions or Processors. In code I’ve enabled the Action and set a callback on .started to print out a debug message. When I play the scene and hit the key, I see the message - good.

But when I poll the value in Update() with action.ReadValue<float>() I’m just getting zero regardless of the keyboard button state. In earlier versions of Input System like 1.1.0-pre.5 this would return 0.0 when not pressed, and 1.0 when pressed. Has this changed in version 1.1.1 (and 1.1.0-pre.6)?

EDIT: I changed the binding to a GamePad’s analog right trigger and that just returns zero too, regardless of actual state.

I created an almost exact duplicate of the scripted Component that has my broken Input Actions on it. I created the exact same set of bindings. Bizarrely, this new set of Input Actions polls the correct values and generally works properly, but the original Input Actions that were present when I upgraded the Input System package do not work at all (always return zero when polled).

What kind of internal state could Input System be keeping? I’ve tried a complete project reimport (deleted the Library folder) and that hasn’t made any difference. I notice that the fields in the .prefab file (that I happen to be using) are slightly different between the older Input Actions and the new ones - in particular the m_Name field in the newer Actions matches the name of the inspector field (at least as per Unity’s normal name mangling rules), whereas my older Actions have legacy names from a long time ago. I may try manually changing those to see if that makes any difference. Everything else in the .prefab file looks prety much the same between both instances, including the m_Path and m_Flags fields in the m_SingletonActionBindings lists.

What else could it be?

I think I’ve worked it out - in my code I am making calls to ReadValue<float>() within FixedUpdate(), as I am using those values to affect physics.

I notice in the Input System Package section of Project Settings, there is “Update Mode: Process Events in [Dynamic|Fixed] Update”. I have mine set to Dynamic. I switched to polling the Action values in Update() and my previous functionality came back to life, all working as expected.

I’ve looked through the 1.1.0-pre.6 changelog and I’m not seeing any obvious changes related to this.

So is my conclusion correct? Is it no longer safe to poll Input Action values in FixedUpdate() if the mode is set to “Process Events in Dynamic Update”? Have I missed something in the docs about this, somewhere?

If someone can shed some light on this change, I’d appreciate it, please. I want to understand why it used to work, and whether it was meant to work, or whether I made a mistake originally and it’s finally bitten me.

2 Likes

FWIW, even thoughj I now have working Input Actions by moving ReadValue() to Update(), I still get the blank Input Debug window and the “ArgumentNullException: Value cannot be null. Parameter name: layoutName” error fairly often.

I found this third-party write-up of Input System from October 2020, not sure which version they used but it will definitely be before 1.1.0-pre.6:

So it seems I wasn’t the only person using ReadValue() in both Update() and FixedUpdate().

I also can’t find any mention of this restriction in the official docs.

I’m starting to wonder if this is a regression or an intended change, given that the Changelog doesn’t mention it. Can anyone advise whether to report a bug or not?

FWIW I filed a bug.

3 Likes

I just ran into a similar issue — I’m on 1.1.1.

My issue: I’m trying to call ReadValue() in FixedUpdate and it’s returning zero. If I move ReadValue to Update, it successfully returns a value. My update mode is set to Dynamic Update in project settings.

@pitchblende Is your bug report something I can vote on to increase visibility? Link?

Sorry you’re in here talking to yourself, but your documenting this has been helpful to me, so thanks. Hopefully we can get a Unity comment on this… @Rene-Damm ?

This tutorial shows successful polling for input in FixedUpdate (timestamp 14:48):

@reinfeldx thanks for responding - talking to myself on these forums isn’t too unusual unfortunately :slight_smile:

My bug report hasn’t been triaged by Unity so there’s no public link yet. Once that’s done, if it’s accepted, I’ll post a link to it here. Last bug I reported took 6 weeks to be triaged so don’t hold your breath. However this one seems serious enough that if I can just get someone at Unity to look at it then it’ll probably be escalated pretty quickly. It breaks Cinemachine out-of-the-box too, so that might help.

Also mentioned here: Version 1.1 and General Update

@reinfeldx also, your situation sounds identical to mine. Just out of curiosity, if you change your Input System Update Mode to Fixed Update, does your original code work properly? In my case it does. In the case I’ve had with Cinemachine, “Smart Update” randomly fails because it dynamically switches between Late Update and Fixed Update according to some internal rule. This causes unusual intermittent interaction anomalies.

Yep, it does.

I also experimented with Manual Update mode, and the following seems to be working for me without issue also:

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController_Tutorial : MonoBehaviour
{
    private TestInputActions testInputActions;
    private InputAction moveAction;

    private void Awake()
    {
        testInputActions = new TestInputActions();
    }

    private void OnEnable()
    {
        moveAction = testInputActions.PlayerDefault.Move;
        moveAction.Enable();

        testInputActions.PlayerDefault.Jump.performed += OnJump;
        testInputActions.PlayerDefault.Jump.Enable();
    }

    private void OnDisable()
    {
        moveAction.Disable();
        testInputActions.PlayerDefault.Jump.performed -= OnJump;
        testInputActions.PlayerDefault.Jump.Disable();
    }

    private void OnJump(InputAction.CallbackContext context)
    {
        Debug.Log("Jumped");
    }

    private void Update()
    {
        // Update the system manually if set to Manual in Project Settings
        InputSystem.Update();
        Debug.Log($"Update movement values: {moveAction.ReadValue<Vector2>()}");
    }

    private void FixedUpdate()
    {
        // Update the system manually if set to Manual in Project Settings
        InputSystem.Update();
        Debug.Log($"FixedUpdate movement values: {moveAction.ReadValue<Vector2>()}");
    }
}

With prior projects I’ve become used to polling for different inputs in Update and FixedUpdate, which is why I tried this. But as I think about it now it might not be necessary due to the event-based approach of the New Input System. It’s my first day with it, so I could be wrong on any of this :slight_smile:

Ok, cool - the more people that reproduce this and report it, the more likely it’ll get addressed. I’ve been through my entire project and moved all ReadValue() calls to Update() only, so I’m no longer blocked by it, but it would be great to see this fixed soon.

Hey folks, just want to let you know that we just landed the fix for this in Swapping InputManager state buffers and update step counts back to latest player update after editor update by jimon · Pull Request #1424 · Unity-Technologies/InputSystem · GitHub it will be part of 1.1.2 which will be released very soon.

The problem was specific to running in play mode in the editor. Reading values from FixedUpdate would return values from last frame’s editor update. We restored behavior from <1.1.0-pre.6 which is reading in FixedUpdate will return last frame’s player data. If you have to get same frames data in FixedUpdate you will need to switch input system to process updates in fixed updates in the project settings.

1 Like

@dmytro_at_unity thanks for the update - glad to see some movement on this.

1 Like