The webglcontextlost event of the WebGL API is fired if the user agent detects that the drawing buffer associated with a WebGLRenderingContext object has been lost.
| Bubbles | Yes |
|---|---|
| Cancelable | Yes |
| Interface | WebGLContextEvent |
| Event handler property | none |
Example
With the help of the WEBGL_lose_context extension, you can simulate the webglcontextlost event:
const canvas = document.getElementById('canvas');
const gl = canvas.getContext('webgl');
canvas.addEventListener('webglcontextlost', (event) => {
console.log(event);
});
gl.getExtension('WEBGL_lose_context').loseContext();
// "webglcontextlost" event is logged.
Specifications
| Specification | Status | Comment |
|---|---|---|
| WebGL 1.0 The definition of 'webglcontextlost' 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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
webglcontextlost event | Chrome Full support 9 | Edge Full support 12 | Firefox Full support 4 | 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 4 | Opera Android Full support 12 | Safari iOS Full support 8 | Samsung Internet Android Full support 1.5 |
Legend
- Full support
- Full support
