Skip to content

Commit

Permalink
Workaround to support older versions of three.js
Browse files Browse the repository at this point in the history
Older versions of three.js (until r125) have the following issue
mrdoob/three.js#21126 present which breaks
certain WebXR experiences like "moonrider" and "construct chess".

This workaround makes sure that any WebGL context is marked as XR
compatible when possible which means that applications no longer have
to mark it manually and in the correct order. This fix is verified to
work on both "moonrider" and "construct chess" and also doesn't break
sample WebGL pages that don't use WebXR.
  • Loading branch information
zakharvoit committed Sep 4, 2023
1 parent cbd5919 commit c08cdef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ CanvasRenderingContext* WebGL2RenderingContext::Factory::Create(
// compatible. This scenario occurs if the GPU process is not using the GPU
// that the VR headset is plugged into. If the GPU process is restarted, the
// WebGraphicsContext3DProvider must be created using the new one.
if (attribs.xr_compatible &&
!WebGLRenderingContextBase::MakeXrCompatibleSync(host)) {
// If xr compatibility is requested and we can't be xr compatible, return a
// context with the flag set to false.
attribs.xr_compatible = false;
}
//
// Wolvic: Ignore xr_compatible flag and try to force any context to be XR
// compatible. This is a workaround for the following bug in three.js
// https://github.com/mrdoob/three.js/issues/21126.
attribs.xr_compatible = WebGLRenderingContextBase::MakeXrCompatibleSync(host);

Platform::GraphicsInfo graphics_info;
std::unique_ptr<WebGraphicsContext3DProvider> context_provider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ CanvasRenderingContext* WebGLRenderingContext::Factory::Create(
// compatible. This scenario occurs if the GPU process is not using the GPU
// that the VR headset is plugged into. If the GPU process is restarted, the
// WebGraphicsContext3DProvider must be created using the new one.
if (attribs.xr_compatible &&
!WebGLRenderingContextBase::MakeXrCompatibleSync(host)) {
// If xr compatibility is requested and we can't be xr compatible, return a
// context with the flag set to false.
attribs.xr_compatible = false;
}
//
// Wolvic: Ignore xr_compatible flag and try to force any context to be XR
// compatible. This is a workaround for the following bug in three.js
// https://github.com/mrdoob/three.js/issues/21126.
attribs.xr_compatible = WebGLRenderingContextBase::MakeXrCompatibleSync(host);

Platform::GraphicsInfo graphics_info;
std::unique_ptr<WebGraphicsContext3DProvider> context_provider(
Expand Down

0 comments on commit c08cdef

Please sign in to comment.