Skip to content

Commit e87d3e1

Browse files
committed
Slightly optimize RenderWebGL.isSupported
twgl's get context tries to enable a bunch of extensions after making the context, which is unnecessary when just probing for webgl being supported
1 parent aca52cb commit e87d3e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/RenderWebGL.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ class RenderWebGL extends EventEmitter {
9797
*/
9898
static isSupported (optCanvas) {
9999
try {
100-
// Create the context the same way that the constructor will: attributes may make the difference.
101-
return !!RenderWebGL._getContext(optCanvas || document.createElement('canvas'));
100+
optCanvas = optCanvas || document.createElement('canvas');
101+
const options = {alpha: false, stencil: true, antialias: false};
102+
return !!(
103+
optCanvas.getContext('webgl', options) ||
104+
optCanvas.getContext('experimental-webgl', options)
105+
);
102106
} catch (e) {
103107
return false;
104108
}

0 commit comments

Comments
 (0)