-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Implement low / high refresh rates on WebXR devices #5217
Conversation
src/core/scene/a-scene.js
Outdated
const rates = xrSession.supportedFrameRates; | ||
if (rates && xrSession.updateTargetFrameRate) { | ||
let targetRate; | ||
if (rates.includes(90)) { |
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.
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?
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.
can this be factored out to a function? setImmersiveModeRefreshRate
. May be the code should be part of the renderer component?
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.
OK, good suggestion - I made this a function on the renderer component & added unit tets for that
src/core/scene/a-scene.js
Outdated
@@ -301,6 +301,19 @@ class AScene extends AEntity { | |||
vrManager.setSession(xrSession).then(function () { | |||
vrManager.setFoveation(rendererSystem.foveationLevel); | |||
}); | |||
const rates = xrSession.supportedFrameRates; |
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.
no const / let only var
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.
Fixed.
Docs & UTs up to date, so I think this is now mergeable. |
Thank you! |
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
highRefreshRate
value 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
highRefreshRate
for 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.