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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox 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 25Edge Mobile Full support 12Firefox Android Full support 4Opera Android Full support 12Safari iOS Full support 8Samsung Internet Android Full support Yes

Legend

Full support  
Full support

See also

Document Tags and Contributors

Contributors to this page: mdnwebdocs-bot, fscholz, jmstfv, nmve, erikadoyle, teoli
Last updated by: mdnwebdocs-bot,