Reputation: 10443
Calling canvas.getContext("webgl");
gets Chrome to trigger the "Rats! WebGL hit a snag" message, and doesn't give any information. How can I fix that?
I'm getting no other information other that canvas.getContext("webgl")
returns null
I would not even know that Chrome fails with a message that takes 25% of the phone screen if I was not using the device myself because this triggers no error.
This is part of a function that is supposed to test if WebGL is supported by creating a new canvas and getting a webGL context:
var webGLIsSupported = function() {
if (typeof window.webGLIsSupported !== 'undefined') {return window.webGLIsSupported;}
var canvas = $('<canvas></canvas>')[0];
var ctx;
try {
ctx = canvas.getContext('webgl'); // <- this triggers the message, and fails
}
catch (e) {
window.webGLIsSupported = false;
return false;
}
window.webGLIsSupported = !!ctx;
return window.webGLIsSupported;
};
Where can I start to get info on what's not working? It's quite frustrating to have no logs whatsoever.
Changing canvas.getContext('webgl')
to canvas.getContext('experimental-webgl')
makes no difference.
I'm running Chrome 49.0.2623.105 on a Samsung S6.
Upvotes: 2
Views: 941
Reputation: 137171
As you noticed, checking for null
is a way to know if the context creation succeeded. But there is no information on the "why" when you only check for it.
There is actually an event which should fire for this exact purpose : webglcontextcreationerror
It does contain a statusMessage
property which should give you more info on the "why" it failed to create the context.
From MDN :
canvas.addEventListener("webglcontextcreationerror", function(e) {
console.log(e.statusMessage || "Unknown error");
}, false);
However, I don't know if you can do anything about the message you got...
Upvotes: 1