Implement low / high refresh rates on WebXR devices#5217
Merged
dmarcos merged 4 commits intoaframevr:masterfrom Jan 16, 2023
Merged
Implement low / high refresh rates on WebXR devices#5217dmarcos merged 4 commits intoaframevr:masterfrom
dmarcos merged 4 commits intoaframevr:masterfrom
Conversation
src/core/scene/a-scene.js
Outdated
| const rates = xrSession.supportedFrameRates; | ||
| if (rates && xrSession.updateTargetFrameRate) { | ||
| let targetRate; | ||
| if (rates.includes(90)) { |
Contributor
Author
There was a problem hiding this comment.
Usually I prefer to avoid "magic numbers" in code, but I'm not sure that replacing these numbers with constants would do anything to aid maintenance or readability.
If you'd like me to use constants like FRAME_RATE_90 etc., please point me to where you'd like them defined. Top of this module? constants/index.js? Or somewhere else?
Member
There was a problem hiding this comment.
can this be factored out to a function? setImmersiveModeRefreshRate. May be the code should be part of the renderer component?
Contributor
Author
There was a problem hiding this comment.
OK, good suggestion - I made this a function on the renderer component & added unit tets for that
dmarcos
reviewed
Jan 13, 2023
src/core/scene/a-scene.js
Outdated
| vrManager.setSession(xrSession).then(function () { | ||
| vrManager.setFoveation(rendererSystem.foveationLevel); | ||
| }); | ||
| const rates = xrSession.supportedFrameRates; |
Contributor
Author
|
Docs & UTs up to date, so I think this is now mergeable. |
Member
|
Thank you! |
Merged
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:
The renderer component offers a property
highRefreshRate.https://aframe.io/docs/1.4.0/components/renderer.html#properties_highrefreshrate
Currently this is only implemented for WebVR.(sets the
highRefreshRatevalue inpresentationAttributes)This means that in WebXR, A-Frame does not influence frame rate, meaning expriences run at the frame rate preferred by the browser. On Quest 2 that is 90fps, which is arguably too high (and often results in experiences missing frames & hitting 45fps).
Changes proposed:
This PR provides a WebXR implementation of the
highRefreshRatefor devices/browsers that support the WebXR API to control frame rate:https://www.w3.org/TR/webxr/#dom-xrsession-updatetargetframerate
Proposed behaviour:
1 - if device does not support 90fps, low -> 60, high -> 72
2 - if device supports 90fps, low -> 72, high -> 90
Currently 1 = Quest 1; 2 = Quest 2 & Quest Pro.
Other browsers / devices do not yet support the WebXR spec linked above, but when they do this seems like sensible default behaviour - it can be further tuned when additional info is known about what frame rates these browsers support.
Other notes
This PR is not ready to merge yet. Sharing for an initial view of what the code / function should be. If we get agreement on that, I'll add UTs & updated documentation to reflect the changes.