Skip to content

Commit cedeb45

Browse files
Clarify that loseContext also frees WebGL resources (#42894)
* Clarify that loseContext also frees WebGL resources * Merge paragraphs * Update restoreContext too --------- Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
1 parent 19cee96 commit cedeb45

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

files/en-us/web/api/webgl_lose_context/losecontext/index.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ browser-compat: api.WEBGL_lose_context.loseContext
88

99
{{APIRef("WebGL")}}
1010

11-
The **WEBGL_lose_context.loseContext()** method is part of the [WebGL API](/en-US/docs/Web/API/WebGL_API) and allows you to simulate losing
12-
the context of a {{domxref("WebGLRenderingContext")}} context.
11+
The **`loseContext()`** method of the `WEBGL_lose_context` extension is part of the [WebGL API](/en-US/docs/Web/API/WebGL_API) and allows you to simulate losing the context of a {{domxref("WebGLRenderingContext")}}.
1312

14-
It triggers the steps described in the WebGL specification for handling context lost.
15-
The context will remain lost until {{domxref("WEBGL_lose_context.restoreContext()")}} is
16-
called.
13+
It triggers the [steps described in the WebGL specification](https://registry.khronos.org/webgl/specs/latest/1.0/#5.15.2) for handling context lost. The context will remain lost until {{domxref("WEBGL_lose_context.restoreContext()")}} is called. It also destroys the underlying graphics context and all graphics resources. This is the recommended mechanism for applications to programmatically halt their use of the WebGL API.
1714

1815
## Syntax
1916

@@ -31,9 +28,7 @@ None ({{jsxref("undefined")}}).
3128

3229
## Examples
3330

34-
With this method, you can simulate the
35-
[`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event)
36-
event:
31+
With this method, you can simulate the [`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event) event:
3732

3833
```js
3934
const canvas = document.getElementById("canvas");
@@ -59,7 +54,4 @@ gl.getExtension("WEBGL_lose_context").loseContext();
5954
## See also
6055

6156
- {{domxref("WebGLRenderingContext.isContextLost()")}}
62-
- Events:
63-
[`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event),
64-
[`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event),
65-
[`webglcontextcreationerror`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event)
57+
- Events: [`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event), [`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event), [`webglcontextcreationerror`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event)

files/en-us/web/api/webgl_lose_context/restorecontext/index.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ browser-compat: api.WEBGL_lose_context.restoreContext
88

99
{{APIRef("WebGL")}}
1010

11-
The **WEBGL_lose_context.restoreContext()** method is part of the [WebGL API](/en-US/docs/Web/API/WebGL_API) and allows you to simulate
12-
restoring the context of a {{domxref("WebGLRenderingContext")}} object.
11+
The **`restoreContext()`** method of the `WEBGL_lose_context` extension is part of the [WebGL API](/en-US/docs/Web/API/WebGL_API) and allows you to simulate restoring the context of a {{domxref("WebGLRenderingContext")}}.
12+
13+
It triggers the [steps described in the WebGL specification](https://registry.khronos.org/webgl/specs/latest/1.0/#5.15.3) for handling context restored. The context is not usable until the {{domxref("HTMLCanvasElement.webglcontextrestored_event", "webglcontextrestored")}} event is fired.
1314

1415
## Syntax
1516

@@ -34,9 +35,7 @@ Browsers may not report WebGL errors by default. WebGL's error reporting works b
3435

3536
## Examples
3637

37-
With this method, you can simulate the
38-
[`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event)
39-
event:
38+
With this method, you can simulate the [`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event) event:
4039

4140
```js
4241
const canvas = document.getElementById("canvas");
@@ -60,7 +59,4 @@ gl.getExtension("WEBGL_lose_context").restoreContext();
6059
## See also
6160

6261
- {{domxref("WebGLRenderingContext.isContextLost()")}}
63-
- Events:
64-
[`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event),
65-
[`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event),
66-
[`webglcontextcreationerror`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event)
62+
- Events: [`webglcontextlost`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event), [`webglcontextrestored`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextrestored_event), [`webglcontextcreationerror`](/en-US/docs/Web/API/HTMLCanvasElement/webglcontextcreationerror_event)

0 commit comments

Comments
 (0)