Skip to content
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

Avoid console warnings when using WebXR Layers #22145

Closed
wants to merge 2 commits into from

Conversation

sigmaxipi
Copy link
Contributor

@sigmaxipi sigmaxipi commented Jul 17, 2021

Fixes #22079

Tested:

  • webxr_vr_layers.html has no warnings on Quest 2
  • Other webxr_vr_* examples are working without issues.

@sigmaxipi
Copy link
Contributor Author

@Mugen87 , can you take a look at this PR? #22079 isn't a critical issue, but triggers every frame and spams the logs.


needsUpdate = true;

} // else avoid https://github.com/mrdoob/three.js/issues/22079 when using XR layers.
Copy link
Collaborator

@Mugen87 Mugen87 Jul 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain in more detail why this fixes the mentioned warnings? TBH, I understand the change so far.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure of the exact flow. But I think the issue is that the system is trying to draw to _gl.BACK when using XR Layers rather than to the WebXR compositor's provided texture. I thought this would result in an error and a black frame since the draw calls would not be sent to the WebXR compositor's render target, but it only seems to be a warning.

Copy link
Collaborator

@Mugen87 Mugen87 Jul 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I can't approve this PR without a closer study of the code. One should also clarify if this is an issue in Oculus Browser.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's understandable. I restricted the code as much as possible so that it only affects devices with layers. At the moment, that's limited to Oculus Browser so there is no other way to test this.

Another option might be to set renderTarget when in WebXR or when layers are active. That would cause the code to go through the if ( renderTarget ) { path above this change. I'll try making that change and see if the results are the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specific issue is that drawBuffers([gl.BACK]) is only valid for the default framebuffer that you get from bindFramebuffer(..., null). However, in WebXR mode, state.bindFramebuffer(..., null) has an override to replace the default framebuffer with the XR framebuffer which is a framebuffer object, and that should use [gl.COLOR_ATTACHMENT0] and not override with [gl.BACK].

This is a general issue that happens when switching render targets while in XR, so it's not specific to WebXR Layers. It also happens when rendering shadows in phone AR mode.

See google/model-viewer#2769 (reply in thread) which has some more details from where I investigated this for model-viewer.

Adding a "is in XR" conditional here would work, but alternatively would it make sense to move the low-level drawBuffers call to WebGLState and apply an override there that replaces gl.BACK with gl.COLOR_ATTACHMENT0 when xrFramebuffer is active?

@sigmaxipi
Copy link
Contributor Author

Discarding this change in favor of #22558

@sigmaxipi sigmaxipi closed this Sep 24, 2021
@sigmaxipi sigmaxipi deleted the logWarning branch September 23, 2022 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings in console on Quest when WebXR layers are enabled.
3 participants