- Notifications
You must be signed in to change notification settings - Fork 328
FIX: ISXB-1584, ISXB-1688, ISXB-1692, ISXB-1693, ISXB-1694, ISXB-1701 InputActionReference bug fixes and improved test coverage. #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…been called and cached, then Set and then calling action again.
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. |
…onReference, simplification of InputActionImporter.
…g fixing of InputActionReference, added more tests.
…to support serialization within editor test. Added test utilities.
…echnologies/InputSystem into isxb-1584-input-action-reference
…ork since referencing editor types.
@jfreire-unity @Pauliusd01 I think I have eliminated the warnings on this branch now. The two key warnings must be present on develop and should be fixed separately. While fixing I realised the associated code could be simplified. |
I guess we should investigate if we can have an automated test that could fail if any warning is generated that maps to our assemblies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to take so long to review.
-
I'm not able to fix the main issue (ISXB-1584) as it now raises an error. I also don't understand what should I do based on the exception logged message.
-
Does this mean that
InputActionReference.Set()
cannot be run at in Play-mode now? -
There's no guidance in the PR description to make the main bug work be fixed with this change. That could have been helpful.
-
I'm much longer to review because there are a lot of things we're fixing in this PR and I'm not familiar with the impact of all the changes.
The only think I have to point out is that to me is that the changes raising an error for ISXB-1584 are a relatively impactfull breaking change, unless I'm seeing this wrong.
If I'm indeed correct, then let's just make this a bit more explicit and add maybe one example in a Discussions post or something. Happy to chat about it.
...m.unity.inputsystem/InputSystem/Editor/PropertyDrawers/InputActionReferencePropertyDrawer.cs Show resolved Hide resolved
Packages/com.unity.inputsystem/InputSystem/Actions/InputActionReference.cs Show resolved Hide resolved
Packages/com.unity.inputsystem/InputSystem/Actions/InputActionReference.cs Show resolved Hide resolved
This is the message I get when opening the ISXB-1584 project in 6.2.0f1 and using the package in this branch:
|
Could you elaborate a bit more on the reproduction steps? Just opening the repo root without doing anything? |
I downloaded the "bug project", used this PR branch, and got that error when entering playmode. I'll test a 3rd time now from scratch |
I now I understand, sorry, Friday-slowness, yes, the repro scenario cannot be allowed. It corrupts the assets. Try the original one if you are curious and see that after exiting playmode, asset A is containing a reference to a sub-asset in asset B...... |
I haven't replied to user yet, but the recommendation will be to instead. reference = InputActionReference.Create(desiredAction); |
Got it. It works, thanks. For some reasons it didn't work before (maybe I had the project with asset already changed by using .Set() without these changes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving now that I managed to solve the customer issue. Good work.
This is a small change in behavior so I think we should communicate this somehow in a Discussions post. I can already predict more bugs related to this change.
Awesome, yeah I found that if you enter playmode once with the repro project you have corrupted the asset beyond what can be resolved by reimport or action editor changes. |
Would probably make sense to provide an example with the release post. Regardless, the existing behaviour is clearly faulty so at least IMO this improves things and leads to less suprises with corrupt assets or cross-asset references. |
Hmmm..... maybe this still causes errors on 2021.3 since that version wouldn't have PWA define |
Confirmed, property drawer is mutating reference via serialised property when used on Unity versions where PWA isn't supported (rather SearchProvider isn't supported), a custom property drawer is also needed before that to not corrupt assets. Will add an update to this PR. |
…ch API and project-wide actions were introduced. Minor test cleanup.
Addressed in 9c7cb44 |
@ekcoh as a sanity check, I would check with packages like XR and Cinemachine if they have any immediate problems with this change. |
Good idea. I am have reached out in appropriate internal channels to see if additional feedback can be collected. |
Moved entries to the Unreleased version in CHANGELOG.md since merge had put them in the wrong place.
According to @windxu88 the Ubuntu instability is expected in CI at the moment |
Been looking at this on and off for a while and it seems fine so far. Still looking into it but got minor notes:
|
Cinemachine team confirmed it doesn't seem to cause any issues with Cinemachine. |
Thanks for the feedback. I look into making that exception message better.
No, it's about doing it programmatically and I have covered it with an automated test that failed when implemented. Then fixed the issue. It's not fundamentally different, but I decided to see ISXB-1584 as the reported problem, that the action wasn't properly updated. This particular one is about corrupting it. There was many things happening at once in 1584 and I just filed specific tickets per problem. This one refers to the part that if you run the repro project without these changes after exiting playmode the first asset (originally containing A), will contain a reference pointing to an action within the asset containing B. |
Description
Fixes the following issues:
InputActionReference.action
would return an incorrect (cached) action if set programmatically after the cached instance had been resolved.InputActionSetupExtensions.RemoveAction(action)
throws exception if attempting to remove an action that doesn't have any bindings.InputActionReference.Set
in playmode corrupts the referenced asset.InputActionReference.Create(null)
returns null instead "of a reference object to the given action". If its desirable to assign a reference to null when action is null, one should not call Create to begin with.InputActionReference.Set(null)
does not update the cached input action reference nor theScriptableObject.name
leading to incorrect action being returned and reference showing up as the path to the previously assigned action in Inspector.ISXB-1699 -This was a misinterpretation and have been reverted. Ticket marked "As Designed".InputActionAsset.RemoveActionMap
doesn't remove actions within the map, leaving them with stale references back to the map.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:
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 toInputActionReference
.InputActionReference
to eliminate name-shadowing warnings. Didn't touch public ones since a parameter rename would be unexpected after API publishing.InputActionReference
instances from assets withinInputActionImporter
.EditorPrefsTestUtils.cs
which is a test utility to simplify editor tests.CoreTests_Actions_References.cs
which extracts previous and newInputActionReference
play-mode tests into their own (partial) file.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:
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
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:
Changed
,Fixed
,Added
sections.Actions_CanResolveActionReferenceAndThenSetItToAnotherAction
During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: