Skip to content

FIX: uum 144337 inputfixture teardown fails to reset input system#2437

Open
Darren-Kelly-Unity wants to merge 4 commits into
developfrom
bugfix/UUM-144337-inputfixture-teardown-fails-to-reset-input-system
Open

FIX: uum 144337 inputfixture teardown fails to reset input system#2437
Darren-Kelly-Unity wants to merge 4 commits into
developfrom
bugfix/UUM-144337-inputfixture-teardown-fails-to-reset-input-system

Conversation

@Darren-Kelly-Unity

@Darren-Kelly-Unity Darren-Kelly-Unity commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Purpose of this PR

Fixes two regressions surfaced by UUM-144337:

  1. InputFixture teardown fails to reset the Input System — after Restore() re-installs the global InputActionState registry, per-map and per-action back-references (m_State, m_MapIndexInState, m_ActionIndexInState) were left stale because Destroy() had cleared them. A new RelinkRestoredStates() pass re-links those references and recomputes m_EnabledActionsCount from the restored action-phase memory. TestHook_DisableActions() is also changed to null the back-references rather than call Disable(), which was corrupting the saved-state snapshot.

  2. Multiple touchscreen input bug on multi-display — touch events were matched solely by touchId, causing collisions when two displays used the same ID. All touch-slot lookups and event-merge checks now also compare displayIndex. TouchSimulation gains a m_TouchDisplayIndices array to propagate the correct displayIndex through simulated touch events.

Release Notes

  • [UUM-144337] Fixed InputTestFixture teardown leaving InputActionMap back-references stale after state restore, causing maps and actions to report incorrect enabled state post-test.
  • [UUM-144337] Fixed touchscreen touch-slot lookup incorrectly matching touches from different displays that share the same touchId, causing phantom or dropped touch inputs in multi-display setups.

Functional Testing status

  • Automated: new InputTestFixtureTeardownTests cover the teardown/restore regression (editor tests).
  • Automated: new TouchscreenMultiDisplayTests cover same-touchId cross-display collision and TouchSimulation displayIndex propagation.
  • Manual: verified existing touchscreen and EnhancedTouch test suites pass without regression.

Performance Testing Status

No performance impact. Changes are confined to test-fixture teardown paths and touch-slot O(n) linear scans that are already present; only an extra integer comparison is added per iteration.

Overall Product Risks

  • Technical Risk: 1 / 3 — Fix is contained to test infrastructure teardown and an existing touch-slot lookup predicate; no public API surface changed.
  • Halo Effect: 1 / 3Touchscreen.OnStateEvent / MergeEvent touch matching is on a hot path, but the change is additive (extra && condition) and covered by new tests.

Class diagram

Changes across b9b935932~3..HEAD.

Class diagram
classDiagram
  direction TB

  class InputTestStateManager {
    +Restore()
  }

  class InputActionState {
    <<partial>>
    +RelinkRestoredStates()$
    -RelinkMapsAndRecomputeEnabledCount()
  }

  class InputActionMap {
    +m_State : InputActionState
    +m_MapIndexInState : int
    +m_EnabledActionsCount : int
  }

  class InputSystem {
    +TestHook_DisableActions()$
    +TestHook_EnableActions()$
  }

  class Touchscreen {
    #OnStateEvent()
    #MergeEvent()
  }

  class TouchSimulation {
    -m_TouchIds : int[]
    -m_TouchDisplayIndices : byte[]
    -m_LastTouchId : int
    +BeginTouch()
  }

  InputTestStateManager --> InputActionState : calls RelinkRestoredStates
  InputActionState --> InputActionMap : relinks m_State + m_MapIndexInState
  InputSystem --> InputActionMap : nulls m_State on teardown
  TouchSimulation --> Touchscreen : simulates events on
Loading

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May require changes

Focused bugfix for the Input System teardown; one critical state restoration step appears to be missing in the action state relinking.

🤖 Helpful? 👍/👎

continue;

map.m_State = this;
map.m_MapIndexInState = mapIndex;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Since TestHook_DisableActions() now explicitly nulls out m_SharedStateForAllMaps on the project-wide action asset, RelinkRestoredStates() needs to restore it here.

Without this, the restored action maps will successfully reconnect their m_State, but their parent InputActionAsset will be left with a null m_SharedStateForAllMaps. This breaks asset-level reactivity: methods like InputActionAsset.bindingMask and InputActionAsset.devices setters rely on ReResolveIfNecessary(), which returns early and does nothing if m_SharedStateForAllMaps == null. As a result, subsequent tests that try to apply overrides to the project-wide asset would see those changes silently ignored.

You can safely restore it using the map's asset reference:

Suggested replacement omitted because it is too large for an inline review comment.

🤖 Helpful? 👍/👎 by bug_hunter_agent

@Darren-Kelly-Unity Darren-Kelly-Unity changed the title Bugfix/uum 144337 inputfixture teardown fails to reset input system FIX: uum 144337 inputfixture teardown fails to reset input system Jun 15, 2026
@codecov-github-com

codecov-github-com Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 96.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nputSystem.Editor/InputTestFixtureTeardownTests.cs 90.00% 2 Missing ⚠️
...em/InputSystem/Runtime/Actions/InputActionState.cs 94.59% 2 Missing ⚠️
@@             Coverage Diff              @@
##           develop    #2437       +/-   ##
============================================
+ Coverage    58.58%   79.03%   +20.45%     
============================================
  Files          738      767       +29     
  Lines       135831   140436     +4605     
============================================
+ Hits         79570   110989    +31419     
+ Misses       56261    29447    -26814     
Flag Coverage Δ
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.49% <96.00%> (+0.23%) ⬆️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.48% <96.00%> (+0.26%) ⬆️
inputsystem_MacOS_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.49% <96.00%> (+0.26%) ⬆️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.53% <96.00%> (+0.26%) ⬆️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.53% <96.00%> (+0.26%) ⬆️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.39% <96.00%> (+0.24%) ⬆️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.39% <96.00%> (+0.26%) ⬆️
inputsystem_Ubuntu_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.40% <96.00%> (+0.26%) ⬆️
inputsystem_Ubuntu_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.44% <96.00%> (+0.27%) ⬆️
inputsystem_Ubuntu_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.44% <96.00%> (+0.27%) ⬆️
inputsystem_Windows_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.61% <96.00%> (+0.24%) ⬆️
inputsystem_Windows_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.60% <96.00%> (+0.26%) ⬆️
inputsystem_Windows_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.61% <96.00%> (+0.26%) ⬆️
inputsystem_Windows_6000.5 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.66% <96.00%> (+0.26%) ⬆️
inputsystem_Windows_6000.6 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6_project 77.66% <96.00%> (+0.27%) ⬆️

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

Files with missing lines Coverage Δ
.../Tests/InputSystem/TouchscreenMultiDisplayTests.cs 100.00% <100.00%> (ø)
...tsystem/InputSystem/Runtime/Devices/Touchscreen.cs 91.26% <100.00%> (+90.96%) ⬆️
...ity.inputsystem/InputSystem/Runtime/InputSystem.cs 82.24% <100.00%> (+76.61%) ⬆️
...m/Runtime/Plugins/EnhancedTouch/TouchSimulation.cs 90.64% <100.00%> (+88.63%) ⬆️
...tsystem/Tests/TestFixture/InputTestStateManager.cs 92.85% <100.00%> (+32.61%) ⬆️
...nputSystem.Editor/InputTestFixtureTeardownTests.cs 90.00% <90.00%> (ø)
...em/InputSystem/Runtime/Actions/InputActionState.cs 92.61% <94.59%> (+92.41%) ⬆️

... and 274 files with indirect coverage changes

ℹ️ Need help interpreting these results?

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.

1 participant