InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

FIX: Autosave closes add control scheme ui element on save. (ISXB-1713)

Open Darren-Kelly-Unity opened this issue 2 months ago β€’ 3 comments

Description

Fix an issue where the control scheme UI would close when pressing the + for adding a device type when there was a pending change to be auto saved.

Ticket: https://jira.unity3d.com/browse/ISXB-1713

Testing status & QA

I have tested this manually in the editor on Unity version 6.000.1.5f1

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: 2
  • Halo Effect: 1

Comments to reviewers

Please describe any additional information such as what to focus on, or historical info for the 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 %<ID>%). 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.

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.

Darren-Kelly-Unity avatar Oct 28 '25 15:10 Darren-Kelly-Unity

PR Reviewer Guide πŸ”

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 πŸ”΅πŸ”΅βšͺβšͺβšͺ

The PR is small with a clear goal, but it contains leftover debugging code and a concerning TODO comment that need to be addressed.
πŸ…Β Score: 70

The PR addresses the bug with a reasonable approach, but it includes several leftover debug logs and a concerning TODO comment that must be removed or clarified before merging.
πŸ§ͺΒ No relevant tests
πŸ”’Β No security concerns identified
⚑ Recommended focus areas for review

Debugging Remnants

The code contains several Debug.LogError statements that appear to be for debugging purposes (e.g., in Save, and in ControlSchemesView.cs). These should be removed before merging. Using LogError for informational logging can also be misleading.

if (isAutoSave)
{
    Debug.LogError("Auto-saving input action asset.");
}
Unresolved TODO

A TODO comment indicates a known issue with the following line of code. This should be investigated and resolved, or the comment should be clarified or removed if it's no longer relevant.

//TODO THIS CAUSES THE ERROR

πŸ€– Helpful? Please react with πŸ‘/πŸ‘Ž | Questions❓Please reach out in Slack #ask-u-pr-agent

u-pr-agent[bot] avatar Oct 28 '25 15:10 u-pr-agent[bot]

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...KAssetEditor/InputActionsEditorSettingsProvider.cs 0.00% 4 Missing :warning:
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 0.00% 4 Missing :warning:
...or/UITKAssetEditor/Views/InputActionsEditorView.cs 0.00% 3 Missing :warning:
@@             Coverage Diff             @@
##           develop    #2268      +/-   ##
===========================================
- Coverage    77.95%   77.91%   -0.04%     
===========================================
  Files          477      476       -1     
  Lines        97419    97465      +46     
===========================================
- Hits         75943    75941       -2     
- Misses       21476    21524      +48     
Flag Coverage Ξ”
inputsystem_MacOS_2022.3 5.54% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_2022.3_project 75.47% <0.00%> (-0.03%) :arrow_down:
inputsystem_MacOS_6000.0 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.0_project 77.36% <0.00%> (-0.06%) :arrow_down:
inputsystem_MacOS_6000.2 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.2_project 77.36% <0.00%> (-0.05%) :arrow_down:
inputsystem_MacOS_6000.3 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.3_project 77.36% <0.00%> (-0.06%) :arrow_down:
inputsystem_MacOS_6000.4 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.4_project 77.36% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.5 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_MacOS_6000.5_project 77.36% <0.00%> (-0.06%) :arrow_down:
inputsystem_Ubuntu_2022.3 5.54% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_2022.3_project 75.27% <0.00%> (-0.03%) :arrow_down:
inputsystem_Ubuntu_6000.0 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_6000.0_project 77.16% <0.00%> (-0.06%) :arrow_down:
inputsystem_Ubuntu_6000.2 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_6000.2_project 77.16% <0.00%> (-0.06%) :arrow_down:
inputsystem_Ubuntu_6000.3 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_6000.3_project 77.16% <0.00%> (-0.06%) :arrow_down:
inputsystem_Ubuntu_6000.4 5.33% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_6000.4_project 77.17% <0.00%> (-0.06%) :arrow_down:
inputsystem_Ubuntu_6000.5 5.33% <0.00%> (-0.01%) :arrow_down:
inputsystem_Ubuntu_6000.5_project 77.17% <0.00%> (-0.06%) :arrow_down:
inputsystem_Windows_2022.3 5.54% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_2022.3_project 75.60% <0.00%> (-0.03%) :arrow_down:
inputsystem_Windows_6000.0 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_6000.0_project 77.49% <0.00%> (-0.06%) :arrow_down:
inputsystem_Windows_6000.2 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_6000.2_project 77.49% <0.00%> (-0.06%) :arrow_down:
inputsystem_Windows_6000.3 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_6000.3_project 77.48% <0.00%> (-0.06%) :arrow_down:
inputsystem_Windows_6000.4 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_6000.4_project 77.49% <0.00%> (-0.05%) :arrow_down:
inputsystem_Windows_6000.5 5.32% <0.00%> (-0.01%) :arrow_down:
inputsystem_Windows_6000.5_project 77.49% <0.00%> (-0.05%) :arrow_down:

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

Files with missing lines Coverage Ξ”
...or/UITKAssetEditor/Views/InputActionsEditorView.cs 53.25% <0.00%> (+9.02%) :arrow_up:
...KAssetEditor/InputActionsEditorSettingsProvider.cs 0.00% <0.00%> (ΓΈ)
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 54.20% <0.00%> (-0.94%) :arrow_down:

... and 14 files with indirect coverage changes

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

codecov-github-com[bot] avatar Oct 28 '25 16:10 codecov-github-com[bot]

It still reproduces with project wide actions view but if it is complicated to fix I'd be fine with merging as is.

Steps to repro: Open project settings -> input system view -> make sure you have a PWA asset if not make one -> make some changes (this window always uses auto save) -> start editing the control scheme as bug repro describes -> focus is lost

https://github.com/user-attachments/assets/f3dfcffa-075c-46d2-a11a-75da6946f51a

Pauliusd01 avatar Oct 31 '25 13:10 Pauliusd01

Thanks for doing this fix @Darren-Kelly-Unity. The staticness of these states look a bit dangerous to me, but if it solves the problem lets land this fix since it quite condensed.

I actually changed it now due to a comment from Rita asking about with two windows open, now I just check the view to see if the ControlScheme is currently active for each instance which is better.

Darren-Kelly-Unity avatar Dec 16 '25 12:12 Darren-Kelly-Unity

/test_plan

Pauliusd01 avatar Dec 16 '25 12:12 Pauliusd01

Test Plan

  • [ ] Test plan approved by PR author
  • [ ] Test execution in progress
  • [x] Test execution complete
  • [x] Ready for merge

Summary of Changes & Risk Assessment

Summary of Changes

This PR fixes a bug (ISXB-1713) where the "Add Control Scheme Device Type" UI element would unexpectedly close when autosave was triggered in the Input Actions Editor window. The fix works by preventing autosave in InputActionsEditorWindow.cs and InputActionsEditorSettingsProvider.cs when the ControlSchemesView is active for that specific editor instance. A new IsControlSchemeViewActive() method was added to InputActionsEditorView.cs to facilitate this check.

Risk Assessment

  • High Risk Areas: None identified.
  • Medium Risk Areas:
    • Potential for autosave not triggering when it should, if the IsControlSchemeViewActive() check is overly broad or incorrect.
    • The fix does not fully resolve the issue for Project Wide Actions (PWA) opened via Project Settings, as noted in the PR comments.
  • Low Risk Areas:
    • Minor changes to Debug.LogWarning message.
    • Leftover debugging logs and a TODO comment in the PR code are noted as needing removal before merge, but don't pose functional risk.

Test Scenarios

Functional Testing

  • [x] Verify Fix (Standalone Editor Window):
    1. Create a new Input Action Asset.
    2. Open it in a standalone Input Actions Editor Window.
    3. Add an Action Map and an Action.
    4. Go to the "Control Schemes" tab.
    5. Click the '+' button to add a new control scheme.
    6. In the new control scheme, click '+' next to 'Device Type' to open the "Add Control Scheme Device Type" popup.
    7. Make a change that would typically trigger autosave (e.g., click outside the popup to dirty the asset, but keep the popup focused).
    8. Expected: The "Add Control Scheme Device Type" popup remains open and does not close due to autosave.
  • [x] Verify Known Limitation (Project Wide Actions in Project Settings):
    1. Open "Project Settings" -> "Input System Package".
    2. Ensure a Project Wide Actions (PWA) asset is selected or create one.
    3. Make some changes to dirty the asset (Project Settings always uses autosave).
    4. Go to the "Control Schemes" tab.
    5. Click the '+' button to add a new control scheme.
    6. In the new control scheme, click '+' next to 'Device Type' to open the "Add Control Scheme Device Type" popup.
    7. Make a change that would typically trigger autosave (e.g., just navigate around in the editor window).
    8. Expected: The "Add Control Scheme Device Type" popup will still close unexpectedly. (This confirms the known limitation from Pauliusd01's comment).
  • [x] Autosave Functionality (General):
    1. Create an Input Action Asset.
    2. Open it in the Input Actions Editor Window.
    3. Make a change (e.g., add an action).
    4. Close the window or unfocus Unity to trigger autosave.
    5. Re-open the asset.
    6. Expected: The changes are saved correctly, and autosave functions as expected when the control scheme UI is not active.

Regression Testing

  • [x] Manual Save Functionality:
    1. Open an Input Action Asset in the editor.
    2. Make changes.
    3. Manually save the asset (Ctrl+S or File -> Save).
    4. Expected: Changes are saved, and no errors occur.
  • [x] Multiple Editor Windows:
    1. Open two different Input Action Assets in two separate Input Actions Editor Windows.
    2. In one window, open the "Add Control Scheme Device Type" popup.
    3. In the other window, make a change to trigger autosave.
    4. Expected: The autosave in the second window completes successfully without closing the popup in the first window.
  • [x] Autosave Disabled:
    1. Disable autosave for Input Action Assets in project settings.
    2. Replicate the steps for "Verify Fix (Standalone Editor Window)".
    3. Expected: The "Add Control Scheme Device Type" popup remains open, and no autosave attempts are made (as expected when autosave is disabled).

πŸ’‘ This test plan updates automatically when /test_plan is run on new commits. If you have any feedback, please reach out in #ai-qa


πŸ€– Helpful? Please react with πŸ‘/πŸ‘Ž | Questions❓Please reach out in Slack #ask-u-pr-agent

u-pr-agent[bot] avatar Dec 16 '25 12:12 u-pr-agent[bot]