Skip to content

Conversation

ekcoh
Copy link
Collaborator

@ekcoh ekcoh commented Sep 29, 2025

Description

Fixes the following issues:

  • https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1584, where InputActionReference.action would return an incorrect (cached) action if set programmatically after the cached instance had been resolved.
  • ISXB-1688 - InputActionSetupExtensions.RemoveAction(action) throws exception if attempting to remove an action that doesn't have any bindings.
  • ISXB-1692 - Assigning an InputActionReference field stored in an .inputactions asset via InputActionReference.Set in playmode corrupts the referenced asset.
  • ISXB-1693 - InputActionReference.Create(null) returns null instead "of a reference object to the given action".
  • ISXB-1694 - InputActionReference.Set(null) does not update the cached input action reference nor the ScriptableObject.name leading to incorrect action being returned and reference showing up as the path to the previously assigned action in Inspector.
  • ISXB-1699 - InputActionAsset.RemoveActionMap doesn't remove actions within the map, leaving them with stale references back to the map. This was a misinterpretation and have been reverted. Ticket marked "As Designed".
  • ISXB-1701 - Inspector field of type InputActionReference isn't reflecting broken reference in case action is deleted from asset, action map is deleted from asset or the asset itself is deleted.

Revisiting/altering fixes of the previous tickets:

The above revisited tickets reference the problem of InputActionReference run-time objects not being reset when exiting play-mode with domain reloads disabled. To get this scenario covered, this scenario is now included in the added editor tests. Tested both with and without domain reloads enabled.

Additional changes made:

  • Simplified code in InputSystemProvider.cs (UITK integration) since there is no reason to use InputActionReference in that class as long as there is no UI to edit it implemented. If such a UI is added later it can easily be converted back to InputActionReference.
  • Renamed function arguments in non-public functions of InputActionReference to eliminate name-shadowing warnings. Didn't touch public ones since a parameter rename would be unexpected after API publishing.
  • Simplified loading code of InputActionReference instances from assets within InputActionImporter.
  • Adds EditorPrefsTestUtils.cs which is a test utility to simplify editor tests.
  • Adds CoreTests_Actions_References.cs which extracts previous and new InputActionReference play-mode tests into their own (partial) file.
  • Adds DumpInputActionReferences.cs which extends "QA Tools" with ability to dump a list of all input action references (loaded + assets) into the console via QA Tools Unity menu.

Open issues/questions to reviewers:

  • Property drawer for input action references is currently conditionally compiled depending on project-wide input actions. This makes little sense now, but if the check is removed we get a dependency on search context that isn't available in that version, so we might want to land this post 2021.3 EoL or add a similar fix for 2021.3? (Currently missing on PR)

Testing status & QA

Added a bunch of functional tests that replicates the problematic scenarios mentioned above. Both play-mode functional tests as well as edit-mode as well as transitional editor-mode to play-mode and play-mode to edit-mode editor tests were added.

Removed some code related to project-wide-actions in property drawer I believe @jfreire-unity added. I do not think it is needed as a special case anymore and I also think it was incorrect to change the users objects.

Altered a previous play-mode fix by @timkeo but it is essentially intact to previous behavior. I think there is opportunity to change this later to only use Object.FindObjectsByType(true) instead of Resources.FindObjectsByType() as an optimisation after this has landed?

Haven''t tested on 2021.3 which might be behaving differently but I do not know if we should bother since it is soon EoL.

Overall Product Risks

  • Complexity: Medium
  • Halo Effect: Large

InputActionReferences are used all over the place so this is a serious bug that can have impact, especially on more complex projects.

Comments to reviewers

Recommend double checking the repro project with this fix.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests added: Actions_CanResolveActionReferenceAndThenSetItToAnotherAction
    • Performance tests. - None
    • Integration tests. - None
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

…been called and cached, then Set and then calling action again.
@ekcoh ekcoh requested review from K-Tone and Pauliusd01 September 29, 2025 20:03
@codecov-github-com
Copy link

codecov-github-com bot commented Sep 29, 2025

Codecov Report

Attention: Patch coverage is 88.95966% with 52 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Assets/Tests/InputSystem.Editor/TestUtils.cs 17.07% 34 Missing ⚠️
...System/Editor/AssetImporter/InputActionImporter.cs 81.48% 5 Missing ⚠️
...system/InputSystem/Actions/InputActionReference.cs 91.83% 4 Missing ⚠️
...pertyDrawers/InputActionReferencePropertyDrawer.cs 73.33% 4 Missing ⚠️
...s/Tests/InputSystem.Editor/EditorPrefsTestUtils.cs 85.71% 3 Missing ⚠️
...utSystem.Editor/InputActionReferenceEditorTests.cs 97.61% 2 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2248      +/-   ##
===========================================
+ Coverage    76.70%   76.86%   +0.15%     
===========================================
  Files          465      469       +4     
  Lines        87919    88257     +338     
===========================================
+ Hits         67442    67835     +393     
+ Misses       20477    20422      -55     
Flag Coverage Δ
inputsystem_MacOS_2021.3 5.94% <20.83%> (+0.02%) ⬆️
inputsystem_MacOS_2021.3_project 78.15% <87.08%> (+0.10%) ⬆️
inputsystem_MacOS_2022.3 5.40% <16.12%> (+0.02%) ⬆️
inputsystem_MacOS_2022.3_project 74.74% <88.20%> (+0.16%) ⬆️
inputsystem_MacOS_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 76.65% <88.74%> (+0.14%) ⬆️
inputsystem_MacOS_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.2_project 76.64% <88.74%> (+0.14%) ⬆️
inputsystem_MacOS_6000.3 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 76.65% <88.74%> (+0.15%) ⬆️
inputsystem_MacOS_6000.4 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 76.65% <88.74%> (+0.14%) ⬆️
inputsystem_Ubuntu_2021.3 5.94% <20.83%> (+0.02%) ⬆️
inputsystem_Ubuntu_2021.3_project 78.04% <87.08%> (+0.08%) ⬆️
inputsystem_Ubuntu_2022.3 5.40% <16.12%> (+0.02%) ⬆️
inputsystem_Ubuntu_2022.3_project 74.54% <88.20%> (+0.14%) ⬆️
inputsystem_Ubuntu_6000.0 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 76.45% <88.74%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.2 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.2_project 76.45% <88.74%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.3 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 76.45% <88.74%> (+0.13%) ⬆️
inputsystem_Ubuntu_6000.4 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 76.45% <88.74%> (+0.12%) ⬆️
inputsystem_Windows_2021.3 5.94% <20.83%> (+0.02%) ⬆️
inputsystem_Windows_2021.3_project 78.28% <87.08%> (+0.07%) ⬆️
inputsystem_Windows_2022.3 5.40% <16.12%> (+0.02%) ⬆️
inputsystem_Windows_2022.3_project 74.87% <88.20%> (+0.14%) ⬆️
inputsystem_Windows_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 76.77% <88.74%> (+0.12%) ⬆️
inputsystem_Windows_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.2_project 76.77% <88.74%> (+0.12%) ⬆️
inputsystem_Windows_6000.3 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 76.77% <88.74%> (+0.12%) ⬆️
inputsystem_Windows_6000.4 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 76.77% <88.74%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...r/InputActionReferencePropertyDrawerEditorTests.cs 100.00% <100.00%> (ø)
Assets/Tests/InputSystem/CoreTests_Actions.cs 97.77% <100.00%> (-0.01%) ⬇️
...s/Tests/InputSystem/CoreTests_Actions_Reference.cs 100.00% <100.00%> (ø)
.../InputSystem/Actions/InputActionSetupExtensions.cs 79.09% <100.00%> (ø)
...s/com.unity.inputsystem/InputSystem/InputSystem.cs 83.44% <100.00%> (+0.39%) ⬆️
...utSystem/Plugins/InputForUI/InputSystemProvider.cs 86.60% <100.00%> (-0.37%) ⬇️
...utSystem.Editor/InputActionReferenceEditorTests.cs 97.61% <97.61%> (ø)
...s/Tests/InputSystem.Editor/EditorPrefsTestUtils.cs 85.71% <85.71%> (ø)
...system/InputSystem/Actions/InputActionReference.cs 89.47% <91.83%> (+30.21%) ⬆️
...pertyDrawers/InputActionReferencePropertyDrawer.cs 65.00% <73.33%> (+65.00%) ⬆️
... and 2 more

... and 9 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ekcoh
Copy link
Collaborator Author

ekcoh commented Sep 29, 2025

This solves the incorrect return value, but it seems it is not enough to solve the reported problem so moving this back to draft mode for more work.

@ekcoh ekcoh changed the title FIX: ISXB-1584 InputActionReference.action returns the incorrect action if set programmatically. FIX: ISXB-1584, ISXB-1690 InputActionReference bug fixes and improved test coverage. Sep 30, 2025
@ekcoh ekcoh changed the title FIX: ISXB-1584, ISXB-1690 InputActionReference bug fixes and improved test coverage. FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. Oct 3, 2025
@ekcoh ekcoh changed the title FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. FIX: ISXB-1593, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. Oct 3, 2025
@ekcoh ekcoh changed the title FIX: ISXB-1593, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. Oct 3, 2025
@ekcoh ekcoh changed the title FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1699, ISXB-1701 InputActionReference bug fixes and improved test coverage. FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1701 InputActionReference bug fixes and improved test coverage. Oct 6, 2025
Copy link
Collaborator

@timkeo timkeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the change to my bug fix and skimmed though some of the other changes.

{
DumpReferences();
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be part of our Input Debugger interface instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, right now I just put it into our QA asset scripts since I did it to investigate bugs and felt it had more value to keep than removing it, but maybe someone would be interested in it. I would say there is no obvious user-value in it, but maybe for ourselves. However, you likely want snapshots and this was simple and sufficient to solve such problems. I do not intend to move it there as part of this PR at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However its handy to be able to see which InputActionReferences exist in memory and on disc as serialised SOs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants