Web/API/HTMLCanvasElement/webglcontextrestored event

From Get docs


The webglcontextrestored event of the WebGL API is fired if the user agent restores the drawing buffer for a WebGLRenderingContext object.

Once the context is restored, WebGL resources such as textures and buffers that were created before the context was lost are no longer valid. You need to reinitialize the state of your WebGL application and recreate resources.


Bubbles Yes
Cancelable Yes
Interface WebGLContextEvent
Event handler property none

Example

With the help of the WEBGL_lose_context extension, you can simulate the webglcontextrestored event:

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');

canvas.addEventListener('webglcontextrestored', function(e) {
  console.log(e); 
}, false);

gl.getExtension('WEBGL_lose_context').restoreContext();

// "webglcontextrestored" event is logged.

Specifications

Specification Status Comment
WebGL 1.0The definition of 'webglcontextrestored' 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
webglcontextrestored 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