This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2018.
The WEBGL_lose_context.restoreContext() method is part of the WebGL API and allows you to simulate restoring the context of a WebGLRenderingContext object.
restoreContext()
None.
None (undefined).
Browsers may not report WebGL errors by default. WebGL's error reporting works by calling getError() and checking for errors. The following exceptions may be thrown:
INVALID_OPERATIONThrown if the context was not lost.
With this method, you can simulate the webglcontextrestored event:
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
canvas.addEventListener(
"webglcontextrestored",
(e) => {
console.log(e);
},
false,
);
gl.getExtension("WEBGL_lose_context").restoreContext();
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
restoreContext |
26 | 17 | 2219–58 | 15 | 8 | 26 | 2219–58 | 14 | 8 | 1.5 | 4.4 | 8 |
WebGLRenderingContext.isContextLost()webglcontextlost, webglcontextrestored, webglcontextcreationerror
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context/restoreContext