Skip to content

FIX: Avoid disabling project-wide actions on shutdown#2346

Open
AswinRajGopal wants to merge 2 commits intodevelopfrom
uum-134130/fix-project-wide-action-onshutdown
Open

FIX: Avoid disabling project-wide actions on shutdown#2346
AswinRajGopal wants to merge 2 commits intodevelopfrom
uum-134130/fix-project-wide-action-onshutdown

Conversation

@AswinRajGopal
Copy link
Collaborator

Description

case: https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-134130

Issue:
UI Toolkit now cleans up its internal objects when no UI component exists in the scene. That means InputSystemProvider.Shutdown() can be called during play. Shutdown() calls UnregisterActions(), which disables m_InputActionAsset. When the provider is using InputSystem.actions (project‑wide actions), this shuts off all input for the game. This is an external side effect and not expected when UI Toolkit goes away.

Fix: Only disable the action asset on shutdown if it is not the project‑wide asset. This keeps the existing init/enable behavior unchanged, but avoids disabling InputSystem.actions when UI Toolkit is shutting down.

Testing status & QA

Added new test.
Verified manually using repro project.

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

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 Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • 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.

@u-pr
Copy link
Contributor

u-pr bot commented Feb 17, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

UUM-134130 - Fully compliant

Compliant requirements:

  • The PR prevents disabling the m_InputActionAsset on shutdown if it matches the global InputSystem.actions.
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪

The PR consists of a single logical check added to one method and a corresponding unit test. The scope is small and well-defined.
🏅 Score: 95

The fix correctly addresses the reported issue by checking against the project-wide actions before disabling. The code is clean, and a regression test is included.
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Test State Cleanup

The test modifies the static state InputSystem.s_Manager.actions (line 111) but does not explicitly reset it to null or its previous value. Although the asset is destroyed (line 119), leaving a reference to a destroyed object in a static manager could potentially affect subsequent tests depending on the test fixture's teardown logic.

InputSystem.s_Manager.actions = asset;

m_InputSystemProvider.Initialize();
Assert.That(asset.enabled, Is.True, "Project-wide actions should be enabled by provider initialization.");

m_InputSystemProvider.Shutdown();
Assert.That(asset.enabled, Is.True, "Project-wide actions must remain enabled after provider shutdown.");

Object.DestroyImmediate(asset);
  • Update review

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@u-pr
Copy link
Contributor

u-pr bot commented Feb 17, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Restore global state after test execution

The test modifies the global static state InputSystem.s_Manager.actions without
restoring it, which can cause side effects or failures in subsequent tests. Wrap the
test logic in a try-finally block to ensure that the original state is restored and
the temporary asset is properly destroyed, even if an assertion fails.

Assets/Tests/InputSystem/Plugins/InputForUITests.cs [111-119]

-InputSystem.s_Manager.actions = asset;
+var originalActions = InputSystem.s_Manager.actions;
+try
+{
+    InputSystem.s_Manager.actions = asset;
 
-m_InputSystemProvider.Initialize();
-Assert.That(asset.enabled, Is.True, "Project-wide actions should be enabled by provider initialization.");
+    m_InputSystemProvider.Initialize();
+    Assert.That(asset.enabled, Is.True, "Project-wide actions should be enabled by provider initialization.");
 
-m_InputSystemProvider.Shutdown();
-Assert.That(asset.enabled, Is.True, "Project-wide actions must remain enabled after provider shutdown.");
+    m_InputSystemProvider.Shutdown();
+    Assert.That(asset.enabled, Is.True, "Project-wide actions must remain enabled after provider shutdown.");
+}
+finally
+{
+    InputSystem.s_Manager.actions = originalActions;
+    Object.DestroyImmediate(asset);
+}
 
-Object.DestroyImmediate(asset);
-
Suggestion importance[1-10]: 8

__

Why: The test modifies the global static state InputSystem.s_Manager.actions. Without a try-finally block, an assertion failure would prevent the restoration of the original state and the destruction of the created asset, potentially causing test pollution and side effects in subsequent tests.

Medium
  • More suggestions

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr

@codecov-github-com
Copy link

codecov-github-com bot commented Feb 17, 2026

Codecov Report

All modified and coverable lines are covered by tests ✅

@@           Coverage Diff            @@
##           develop    #2346   +/-   ##
========================================
  Coverage    77.95%   77.96%           
========================================
  Files          476      476           
  Lines        97453    97537   +84     
========================================
+ Hits         75971    76043   +72     
- Misses       21482    21494   +12     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_MacOS_2022.3_project 75.48% <ø> (+0.01%) ⬆️
inputsystem_MacOS_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.35% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.35% <100.00%> (-0.02%) ⬇️
inputsystem_MacOS_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.36% <100.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.36% <100.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_Ubuntu_2022.3_project 75.28% <ø> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.15% <100.00%> (-0.02%) ⬇️
inputsystem_Ubuntu_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.15% <100.00%> (-0.02%) ⬇️
inputsystem_Ubuntu_6000.4 5.33% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.16% <100.00%> (-0.02%) ⬇️
inputsystem_Ubuntu_6000.5 5.33% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.16% <100.00%> (-0.02%) ⬇️
inputsystem_Windows_2022.3 5.54% <ø> (+<0.01%) ⬆️
inputsystem_Windows_2022.3_project 75.61% <ø> (+0.01%) ⬆️
inputsystem_Windows_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.48% <100.00%> (-0.02%) ⬇️
inputsystem_Windows_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.48% <100.00%> (-0.02%) ⬇️
inputsystem_Windows_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.48% <100.00%> (-0.02%) ⬇️
inputsystem_Windows_6000.5 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.48% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...ssets/Tests/InputSystem/Plugins/InputForUITests.cs 96.88% <100.00%> (+0.17%) ⬆️
...utSystem/Plugins/InputForUI/InputSystemProvider.cs 86.30% <100.00%> (-0.30%) ⬇️

... and 2 files with indirect coverage changes

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

@AswinRajGopal AswinRajGopal removed the request for review from Pauliusd01 February 17, 2026 11:43
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

Comments