Suppressing the "Rats! WebGL hit a snag." error bar in Google Chrome Suppressing the "Rats! WebGL hit a snag." error bar in Google Chrome google-chrome google-chrome

Suppressing the "Rats! WebGL hit a snag." error bar in Google Chrome


If you want to ignore the exception, then the following should be enough.

canvas.addEventListener("webglcontextlost", function(e) { e.preventDefault(); Stopdrawing(); }, false); 

If you want to retry loading the webgl context

canvas.addEventListener("webglcontextrestored", function (event) {initializeResources();  }, false);

EDIT:

If you want to test if the context get handled correctly then make use of the WEBGL_lose_context extension on the webgl context.

gl.getExtension("WEBGL_lose_context").loseContext()gl.getExtension("WEBGL_lose_context").restoreContext()


Took me ages to solve this problem - it seems that the Rats! error came about when resizing a canvas which had a 3D context based on it when using Chrome. The solution was to catch the resize via a listener and recreate the canvas and context at that point. Hope that helps.