InputSystem
InputSystem copied to clipboard
CHANGE: Refactor class conditional guards
Description
Moves around some conditional guards so that we don't unnecessarily wrap entire classes. This stops downstream packages from having to also wrap Input System objects with similar conditionals.
Only device class definitions that get replaced by specific packages should be entirely wrapped.
This PR is a copy of the internal PR created here: https://github.cds.internal.unity3d.com/unity/com.unity.inputsystem/pull/5
Changes made
Removes #if UNITY_INPUT_SYSTEM_ENABLE_XR && (ENABLE_VR || UNITY_GAMECORE) && !PACKAGE_DOCS_GENERATION
guards from wrapping entire class files under InputSystem/Plugins/XR/Devices and InputSystem/Plugins/XR/Haptics.
This makes it so any packages that want to use these Input System package objects don't have to also wrap the use of those objects with #if ENABLE_VR guards. Classes that should ignore Package Generation have been added to the filter.yml file.
We now only wrap the use of device descriptors with #if UNITY_INPUT_SYSTEM_ENABLE_XR to prevent use when the XR Module package is not installed.
Testing status & QA
Engines Supported: 6.2, 6.1, 6.0, 2022.3, 2021.3
Test 1:
-
Create project (or use an existing one)
-
Install Input System package
-
Install OpenXR package (this package uses the Input System but currently does not wrap any objects).
-
Switch platform from Standalone or Android into tvOS or QNX (ENABLE_VR conditional wont be defined on these platforms)
Expected result: No compiler errors
Test 2:
-
Create project (or use an existing one)
-
Install Input System package.
-
Install the com.unity.xr.oculus, com.unity.xr.openvr, and com.unity.xr.windowsmr packages (these packages override certain device class definitions).
Expected result: No compiler errors
Test 3:
-
Create project (or use an existing one)
-
Install Input System package.
-
Implement something that tries to leverage an XRHMD or XRController object
-
Switch platform to tvOS or QNX (ENABLE_VR conditional wont be defined on these platforms)
-
Execute code in Editor or in a build for the new platform.
Expected result: No runtime errors
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:
- Halo Effect:
Comments to reviewers
Please describe any additional information such as what to focus on, or historical info for the reviewers.
Checklist
Before review:
- [x] Changelog entry added.
- Explains the change in
Changed,Fixed,Addedsections. - 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".
- Explains the change in
- [x] Tests added/changed, if applicable.
- Functional tests
Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult. - Performance tests.
- Integration tests.
- Functional 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.
should add @ekcoh
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
@@ Coverage Diff @@
## develop #2183 +/- ##
===========================================
+ Coverage 67.78% 67.79% +0.01%
===========================================
Files 367 367
Lines 53528 53528
===========================================
+ Hits 36285 36291 +6
+ Misses 17243 17237 -6
| Flag | Coverage Δ | |
|---|---|---|
| mac_2021.3_pkg | 5.41% <ø> (ø) |
|
| mac_2021.3_project | 70.43% <ø> (ø) |
|
| mac_2022.3_pkg | 5.19% <ø> (ø) |
|
| mac_2022.3_project | 65.29% <ø> (ø) |
|
| mac_6000.0_pkg | 5.20% <ø> (ø) |
|
| mac_6000.0_project | 67.71% <ø> (ø) |
|
| mac_6000.1_pkg | 5.20% <ø> (ø) |
|
| mac_6000.1_project | 67.71% <ø> (ø) |
|
| mac_6000.2_pkg | 5.20% <ø> (ø) |
|
| mac_6000.2_project | 67.70% <ø> (ø) |
|
| mac_trunk_pkg | 5.20% <ø> (ø) |
|
| mac_trunk_project | 67.70% <ø> (ø) |
|
| win_2021.3_pkg | 5.42% <ø> (ø) |
|
| win_2021.3_project | 70.50% <ø> (ø) |
|
| win_2022.3_pkg | 5.19% <ø> (ø) |
|
| win_2022.3_project | 65.36% <ø> (-0.01%) |
:arrow_down: |
| win_6000.0_pkg | 5.20% <ø> (ø) |
|
| win_6000.0_project | 67.78% <ø> (+<0.01%) |
:arrow_up: |
| win_6000.1_pkg | 5.20% <ø> (ø) |
|
| win_6000.1_project | 67.78% <ø> (ø) |
|
| win_6000.2_pkg | 5.20% <ø> (ø) |
|
| win_6000.2_project | 67.79% <ø> (+0.01%) |
:arrow_up: |
| win_trunk_pkg | 5.20% <ø> (ø) |
|
| win_trunk_project | 67.78% <ø> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| ...tsystem/InputSystem/Plugins/XR/Devices/GoogleVR.cs | 0.00% <ø> (ø) |
|
| ...putsystem/InputSystem/Plugins/XR/Devices/Oculus.cs | 0.00% <ø> (ø) |
|
| ...putsystem/InputSystem/Plugins/XR/Devices/OpenVR.cs | 0.00% <ø> (ø) |
|
| ...system/InputSystem/Plugins/XR/Devices/WindowsMR.cs | 0.00% <ø> (ø) |
|
| ...utsystem/InputSystem/Plugins/XR/GenericXRDevice.cs | 87.87% <ø> (ø) |
|
| ...m/InputSystem/Plugins/XR/Haptics/BufferedRumble.cs | 0.00% <ø> (ø) |
|
| ...Plugins/XR/Haptics/GetCurrentHapticStateCommand.cs | 0.00% <ø> (ø) |
|
| ...Plugins/XR/Haptics/GetHapticCapabilitiesCommand.cs | 0.00% <ø> (ø) |
|
| ...m/Plugins/XR/Haptics/SendBufferedHapticsCommand.cs | 0.00% <ø> (ø) |
|
| ...tem/Plugins/XR/Haptics/SendHapticImpulseCommand.cs | 0.00% <ø> (ø) |
|
| ... and 2 more |
... and 2 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.
@Pauliusd01 I'm adding you just to make sure there's no breakage. Going through the tests mentioned in the PR description should be enough
Nice to see simplifications of compile time symbols which this code base already has too many off. I am not sure about the historical reason why XR defies are conditionally compiled at all since this is not done for e.g. Keyboards, Mice, Gamepads, Touchpads or other device types. Maybe you can remind me why we need to conditionally compile these at all? I suspect it is to remove them when no runtime backing them up is present, but generally I wonder if the API should be dynamic like this since it adds complexity and compile time burden.
Thanks for your review. The problem is that we should have never wrapped entire classes conditionally because this causes every package that uses the Input System to also implement conditionals unnecessarily. We should only wrap necessary types that depend on the XR Module package or for calls that may try to invoke native functions from the XR Module packages.
Regarding the rest of your comments, all the comment changes in this PR were to stop Yamato XML errors that were previously hidden. At this point I would very much like this PR to get merged and the Input Team to come back and update any comments that aren't sufficient
@jdiehlUnity and maybe @Pauliusd01 We have a blocking issue with the QNX release. I think it's related to this PR but still looking into it. https://unity-ci.cds.internal.unity3d.com/job/54188255
In the PR description there is a test case section that mentions: Switch platform from Standalone or Android into tvOS or QNX (ENABLE_VR conditional wont be defined on these platforms)
It also mentions "expected results". But it's not clear if the tests were run and what the "actual results" were.
Do you know if the test cases were actually performed or if they were just planned test cases?