Skip to content

Commit

Permalink
Fixed XR Layer rendering race condition with session initialization a…
Browse files Browse the repository at this point in the history
…nd RenderState Update (#5489)

* Fixed XR Layer rendering race condition with session initialization and RenderState update.

* Execute enterVRSuccess after xrSession is fully initialized.
  • Loading branch information
zjm-meta committed Mar 8, 2024
1 parent a9a160b commit 77af389
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/components/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ module.exports.Component = registerComponent('layer', {
return;
}
xrSession.requestReferenceSpace('local-floor').then(this.onRequestedReferenceSpace);
this.needsRedraw = true;
this.layerEnabled = true;
if (this.quadPanelEl) {
this.quadPanelEl.object3D.visible = false;
Expand Down
9 changes: 4 additions & 5 deletions src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,19 +299,18 @@ class AScene extends AEntity {
self.usedOfferSession |= useOfferSession;
requestSession(xrMode, xrInit).then(
function requestSuccess (xrSession) {
self.xrSession = xrSession;

if (useOfferSession) {
self.usedOfferSession = false;
}

vrManager.layersEnabled = xrInit.requiredFeatures.indexOf('layers') !== -1;
vrManager.setSession(xrSession).then(function () {
vrManager.setFoveation(rendererSystem.foveationLevel);
self.xrSession = xrSession;
self.systems.renderer.setWebXRFrameRate(xrSession);
xrSession.addEventListener('end', self.exitVRBound);
enterVRSuccess(resolve);
});
self.systems.renderer.setWebXRFrameRate(xrSession);
xrSession.addEventListener('end', self.exitVRBound);
enterVRSuccess(resolve);
},
function requestFail (error) {
var useAR = xrMode === 'immersive-ar';
Expand Down

0 comments on commit 77af389

Please sign in to comment.