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 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

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
webglcontextlost eventChrome Full support 9Edge Full support 12Firefox Full support 4IE Full support 11Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support 25Firefox Android Full support 4Opera Android Full support 12Safari iOS Full support 8Samsung Internet Android Full support 1.5

Legend

Full support
Full support

See also