HTMLCanvasElement: webglcontextlost event
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 | No |
|---|---|
| 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 |
|---|
| WebGL Specification # 5.15.2 |
Browser compatibility
BCD tables only load in the browser