diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index 58215c2c4..ffbe53f4b 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -122,10 +122,12 @@ class RenderWebGL extends EventEmitter { try { optCanvas = optCanvas || document.createElement('canvas'); const options = {alpha: false, stencil: true, antialias: false}; + // Don't use twgl's getContext here because it will spend a few milliseconds enabling extensions + // on a context that won't get used. return !!( + optCanvas.getContext('webgl2', options) || optCanvas.getContext('webgl', options) || - optCanvas.getContext('experimental-webgl', options) || - optCanvas.getContext('webgl2', options) + optCanvas.getContext('experimental-webgl', options) ); } catch (e) { return false; @@ -145,11 +147,7 @@ class RenderWebGL extends EventEmitter { antialias: false, powerPreference: RenderWebGL.powerPreference }; - // getWebGLContext = try WebGL 1.0 only - // getContext = try WebGL 2.0 and if that doesn't work, try WebGL 1.0 - // getWebGLContext || getContext = try WebGL 1.0 and if that doesn't work, try WebGL 2.0 - return twgl.getWebGLContext(canvas, contextAttribs) || - twgl.getContext(canvas, contextAttribs); + return twgl.getContext(canvas, contextAttribs); } /**