immersive-web / webxr-polyfill

Use the WebXR Device API today, providing fallbacks to native WebVR 1.1 and Cardboard
Apache License 2.0
381 stars 84 forks source link

XRSession requestAnimationFrame should use a single device rAF #115

Closed lojjic closed 4 years ago

lojjic commented 4 years ago

Currently each call to xrSession.requestAnimationFrame() results in a new frame request to the underlying device. This is fine if only one rAF callback is added within a single frame, but if more than one is added then this causes problems, such as poor frame rate and artifacts due to vrDisplay.submitFrame() being called more than once a frame.

The solution here is to maintain a single rAF to the underlying device, and have multiple session.rAFs just add to an array of callbacks that are flushed in the single device rAF. That's also basically what's described in the XR Animation Frame algorithm in the spec.

lojjic commented 4 years ago

I'm currently working up a PR for this.

lojjic commented 4 years ago

See PR #116

lojjic commented 4 years ago

Fixed by PR #116 - closing.