Web/API/HTMLCanvasElement/webglcontextcreationerror event
The webglcontextcreationerror
event of the WebGL API is fired if the user agent is unable to create a WebGLRenderingContext
context.
This event has a WebGLContextEvent.statusMessage
property, which can contain a platform dependent string with more information about the failure.
Bubbles | Yes |
Cancelable | Yes |
Interface | WebGLContextEvent
|
Event handler property | none |
Example
var canvas = document.getElementById('canvas');
canvas.addEventListener('webglcontextcreationerror', function(e) {
console.log(e.statusMessage || 'Unknown error');
}, false);
var gl = canvas.getContext('webgl');
// logs statusMessage or "Unknown error" if unable to create WebGL context
Specifications
Specification | Status | Comment |
WebGL 1.0The definition of 'webglcontextcreationerror' in that specification. | Recommendation | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
webglcontextcreationerror event
|
Chrome
Full support 9 |
Edge
Full support 12 |
Firefox
Full support 49 |
IE
Full support 11 |
Opera
Full support 12 |
Safari
Full support 5.1 |
WebView Android
Full support Yes |
Chrome Android
Full support 25 |
Firefox Android
Full support 49 |
Opera Android
Full support 12 |
Safari iOS
Full support 8 |
Samsung Internet Android
Full support 1.5 |
Legend
- Full support
- Full support
See also
WebGLContextEvent
WebGLRenderingContext.isContextLost()
WEBGL_lose_context
,WEBGL_lose_context.loseContext()
,WEBGL_lose_context.restoreContext()
HTMLCanvasElement: webglcontextcreationerror event by Mozilla Contributors is licensed under CC-BY-SA 2.5.