Web/API/HTMLCanvasElement/webglcontextlost event

From Get docs


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.0The definition of 'webglcontextlost' in that specification. Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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


See also