From f8c1a1ec30af8a2393ae6b4e5b084bab29e4e756 Mon Sep 17 00:00:00 2001 From: Marshall Quander <marshall@quander.me> Date: Thu, 21 Jun 2018 15:52:10 -0700 Subject: [PATCH] Don't do extra work for float texture support --- src/utils/webgl.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/utils/webgl.js b/src/utils/webgl.js index 17b608b34..503f96f43 100644 --- a/src/utils/webgl.js +++ b/src/utils/webgl.js @@ -16,20 +16,21 @@ function checkFloatTextureSupport() { renderer.dispose(); return result; } -const supportsFloatTextures = checkFloatTextureSupport(); export function patchWebGLRenderingContext() { - const originalGetExtension = WebGLRenderingContext.prototype.getExtension; - function patchedGetExtension(name) { + if (/Android.+Firefox/.test(navigator.userAgent)) { // It appears that Galaxy S6 devices falsely report that they support // OES_texture_float in Firefox. This workaround disables float textures // for those devices. // See https://github.com/mozilla/hubs/issues/32 and // https://bugzilla.mozilla.org/show_bug.cgi?id=1338656 - if (name === "OES_texture_float" && /Android.+Firefox/.test(navigator.userAgent) && !supportsFloatTextures) { - return null; - } - return originalGetExtension.call(this, name); + const originalGetExtension = WebGLRenderingContext.prototype.getExtension; + const supportsFloatTextures = checkFloatTextureSupport(); + WebGLRenderingContext.prototype.getExtension = function patchedGetExtension(name) { + if (name === "OES_texture_float" && !supportsFloatTextures) { + return null; + } + return originalGetExtension.call(this, name); + }; } - WebGLRenderingContext.prototype.getExtension = patchedGetExtension; } -- GitLab