files/en-us/web/api/webglrenderingcontext/iscontextlost/index.md
{{APIRef("WebGL")}}{{AvailableInWorkers}}
The
WebGLRenderingContext.isContextLost() method returns a
boolean value indicating whether or not the WebGL context has been lost and
must be re-established before rendering can resume.
isContextLost()
None.
A boolean value which is true if the context is lost, or
false if not.
There are several reasons why a WebGL context may be lost, making it necessary to re-establish the context before resuming rendering. Examples include:
For example, when checking for program linking success, you could also check if the context is not lost:
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS) && !gl.isContextLost()) {
const info = gl.getProgramInfoLog(program);
console.log(`Error linking program:\n${info}`);
}
{{Specifications}}
{{Compat}}