Repository navigation
FIX: [UUM-139700] Inherit canRunInBackground from the base layout - #2498
Open
chris-at-unity wants to merge 2 commits into
Open
chris-at-unity wants to merge 2 commits into
chris-at-unity wants to merge 2 commits into
Conversation
MergeLayout inherited updateBeforeRender from the base layout but not canRunInBackground. Generated XR HMD layouts therefore lost XRHMD's canRunInBackground = true and fell back to QueryCanRunInBackground, whose result is cached for the device's lifetime. If that query failed while the XR provider was reconnecting devices after an app pause, the HMD was reset on every focus loss and the view froze at the tracking origin. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
chris-at-unity
marked this pull request as ready for review
October 16, 2026 00:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When an XR headset's OS menu is brought up, after the device went to sleep and waked up while and an XR app is running in the background, the app's environment would be locked to a floor-level view with no position nor rotation tracking. This process was not always consistent, it would take some sleep-awake cycles before the behavior showed up. This issue was reported for both Meta Quest and Android XR headsets, although the behavior was more readily reproduced on Android XR systems.
The root cause of the bug is that when an XR app is paused, the XRInputSubsystem react by stopping the XR plugins, disconnecting all associated XR devices, which includes the XRHMD device used for tracking position and rotation of the XR headset. Then, when the app is resumed, the devices are reconnected again. This in turn causes the freshly created XRHMD device to be regenerated at runtime. This input device is generated entirely from scratch by the XRLayoutBuilder.Build method using the GenericXRDevice layout as template. Then, the Input System attempts to use the previous device to pass over parameters to the new instance. However, only a subset of parameters is copied between instances, being the canRunInBackground parameter missing from the process. This causes the new XRHMD device unable to run in background, causing the loss of tracking when the app is paused due to the OS menu taking focus. This parameter is cached, so there's no way to recover the tracking through the device alone.
The proposed fixes address this cause by introducing a new mechanism that makes sure the canRunInBackground parameter is also transferred before the new device is initialized. This ensures new devices inherit the capability of running on background if the original device also supported it.
Testing status & QA
Manual testing steps:
Added automated tests to verify that canRunInBackground parameter in the XR HMD device is preserved, and that XRInputSubsystem can disambiguate a disconnect-reconnect cycle for the same device.
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.
Comments to reviewers
This PR is compliment to an internal backport PRs that address the same issue. See the ticket for more details and the internal PRs.
Checklist
Before review:
Changed,Fixed,Addedsections.Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.