Search Issue Tracker

Fixed in 1.3.X

Votes

2

Found in [Package]

1.1.0-preview.2

Issue ID

1293556

Regression

No

[Input System] NullReferenceException error when changing PlayerInput.uiInputModule

Package: Input System

-

How to reproduce:
1. Open the user's attached project (case_1293556-Bug_report_input_system.zip)
2. Play the "TestScene"
3. Observe the console

Expected result: No errors in the console
Actual result: NullReferenceException error in console

Reproducible with: 2019.4.16f1, 2020.1.17f1, 2020.2.0f1, 2021.1.0a9 (1.0.1, 1.1.0-preview.2)
Could not test with: 2018.4.30f1 (no Input System package)

Error:
NullReferenceException: Object reference not set to an instance of an object
UnityEngine.InputSystem.UI.InputSystemUIInputModule.UpdateReferenceForNewAsset (UnityEngine.InputSystem.InputActionReference actionReference) (at Library/PackageCache/com.unity.inputsystem@1.0.1/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:1650)
UnityEngine.InputSystem.UI.InputSystemUIInputModule.set_actionsAsset (UnityEngine.InputSystem.InputActionAsset value) (at Library/PackageCache/com.unity.inputsystem@1.0.1/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:1672)
UnityEngine.InputSystem.PlayerInput.set_uiInputModule (UnityEngine.InputSystem.UI.InputSystemUIInputModule value) (at Library/PackageCache/com.unity.inputsystem@1.0.1/InputSystem/Plugins/PlayerInput/PlayerInput.cs:732)
ChangeUIInputModule.Start () (at Assets/ChangeUIInputModule.cs:13)

  1. Resolution Note (fix version 1.3):

    Fixed in Input System 1.3.0 (available in 2019.4 and above)

Comments (1)

  1. Orororo

    Dec 16, 2020 13:08

    Just adding this :
    as a workaround, I tried to set the PlayerInput.actions to null prior to setting the new uiInputModule. The null reference error is gone but it causes memory leak in the native collections.
    The leak :

    A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
    Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
    UnityEngine.InputSystem.Utilities.ArrayHelpers:Resize(NativeArray`1&, Int32, Allocator) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Utilities\ArrayHelpers.cs:208)
    UnityEngine.InputSystem.InputControlList`1:set_Capacity(Int32) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Controls\InputControlList.cs:101)
    UnityEngine.InputSystem.InputControlList`1:.ctor(Allocator, Int32) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Controls\InputControlList.cs:164)
    UnityEngine.InputSystem.InputControlScheme:PickDevicesFrom(InputControlList`1, InputDevice) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Actions\InputControlScheme.cs:351)
    UnityEngine.InputSystem.Users.InputUser:UpdateControlSchemeMatch(Int32, Boolean) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Plugins\Users\InputUser.cs:1317)
    UnityEngine.InputSystem.Users.InputUser:UnpairDevices() (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Plugins\Users\InputUser.cs:637)
    UnityEngine.InputSystem.PlayerInput:AssignUserAndDevices() (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Plugins\PlayerInput\PlayerInput.cs:1334)
    UnityEngine.InputSystem.PlayerInput:set_actions(InputActionAsset) (at Library\PackageCache\com.unity.inputsystem@1.0.0\InputSystem\Plugins\PlayerInput\PlayerInput.cs:330)

Add comment

Log in to post comment