Search Unity

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

Bug Input System 1.7.0 ArgumentException: "capacity cannot be smaller than size"

Discussion in 'Input System' started by beevik_, Sep 19, 2023.

  1. beevik_

    beevik_

    Joined:
    Sep 27, 2020
    Posts:
    92
    After upgrading from Unity 2022.3.5f1 to 2023.1.13f1, our project started occasionally getting the following exception when using a Nintendo Switch gamepad controller on Mac:

    ArgumentException: capacity(323590) cannot be smaller than size(323592)
    Parameter name: capacityInBytes
    UnityEngine.InputSystem.LowLevel.InputEventBuffer..ctor (UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr, System.Int32 eventCount, System.Int32 sizeInBytes, System.Int32 capacityInBytes) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Events/InputEventBuffer.cs:120)
    UnityEngine.InputSystem.LowLevel.InputEventStream.Close (UnityEngine.InputSystem.LowLevel.InputEventBuffer& eventBuffer) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/Events/InputEventStream.cs:58)
    UnityEngine.InputSystem.InputManager.OnUpdate (UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, UnityEngine.InputSystem.LowLevel.InputEventBuffer& eventBuffer) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/InputManager.cs:3390)
    UnityEngine.InputSystem.LowLevel.NativeInputRuntime+<>c__DisplayClass7_0.<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType updateType, UnityEngineInternal.Input.NativeInputEventBuffer* eventBufferPtr) (at ./Library/PackageCache/com.unity.inputsystem@1.7.0/InputSystem/NativeInputRuntime.cs:65)
    UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*)
    UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at /Users/bokken/build/output/unity/unity/Modules/Input/Private/Input.cs:120)
    UnityEngineInternal.Input.NativeInputSystem:Update(NativeInputUpdateType)
    UnityEngine.InputSystem.InputSystem:Update()


    Some additional info:
    1. The reported capacity is always exactly 2 bytes smaller than the reported size.
    2. The bug happens rarely and is difficult to reproduce. Once it starts happening, the input system reports the exception over and over again.
    3. The bug has so far surfaced only on Mac (intel-based) with a Nintendo Switch gamepad connected via bluetooth. I am not sure if it would happen with other controllers or platforms.
    4. This is happening in the editor. Unsure if it happens in the built player client.
     
    Last edited: Sep 19, 2023