Skip to content Skip to sidebar Skip to footer

Webgl Detected As Supported When It Is Actually Not

I am using WebGL from a WebView in Android. For detecting whether WebGL is supported or not, I am using this function. Android KitKat devices do not have WebGL support enabled, as

Solution 1:

I've had similar experiences with Android devices. Solved by blacklisting Android browser (and, if I understand correctly, stock web view as well). Updated Chrome usually works fine.

Solution 2:

In line with @kirill-dmitrenko's answer, but avoiding parsing User Agents, I have blacklisted all browsers that do not support the "let" construct (http://caniuse.com/#feat=let), which though unrelated, seems to be supported by all modern browsers supporting webgl:

var supported;

try {
    var canvas = document.createElement('canvas');
    supported = !! window.WebGLRenderingContext && (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'));
} catch(e) { supported = false; }

try {
    // let is by no means required, but will help us rule out some old browsers: http://caniuse.com/#feat=leteval('let foo = 123;');
} catch (e) { supported = false; }

if (supported === false) {
    console.log("WebGL is not supported");
}

Post a Comment for "Webgl Detected As Supported When It Is Actually Not"