Bug 218305
| Summary: | WebGL context remains in memory after calling loseContext() | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Philip <philipbell> |
| Component: | WebGL | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | dino, jdarpinian, kbr, kkinnunen, maggotfish, noam, smoley, takashi.th.hasegawa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 14 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Philip
To reproduce:
Create over 16 WebGL contexts and call loseContext on each.
On the 17th call two errors will be thrown:
> ‘There are too many active WebGL contexts on this page, the oldest context will be lost.’
> ‘WebGL: INVALID_OPERATION: loseContext: context already lost’
It's expected that these contexts would not remain in memory.
Code snippet:
for (let i = 0; i < 17; i++) {
const canvas = document.createElement('canvas');
const gl = canvas.getContext('webgl');
const extension = gl.getExtension('WEBGL_lose_context')
extension.loseContext();
}
Example CodePen of dynamically losing & restoring contexts.
https://codepen.io/philipbell/pen/RwRQGmo
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Smoley
Thanks for filing! Apple Internal see rdar://35920437.
Radar WebKit Bug Importer
<rdar://problem/70838378>
Philip
Some additional context:
loseContext is used in popular WebGL libraries including Three.js and PixiJS.
Without this method their context management code fails.
Three.js manages context directly in the renderer code:
https://github.com/mrdoob/three.js/blob/3989bb4a00a9f38b1df5dc02bcbc1e5a1b80df53/src/renderers/WebGLRenderer.js#L345-L357
PixiJS has a component dedicated to context management:
https://github.com/pixijs/pixi.js/blob/9ff49a23670bdb0ed864d4e53fb91d524eab59f2/packages/core/src/context/ContextSystem.ts#L248-L262
Yehonatan Daniv
Looks like a duplicate of this: https://bugs.webkit.org/show_bug.cgi?id=200031
At Wix we use Kampos (https://github.com/wix/kampos), which doesn't use the WEBGL_lose_context plugin, but still getting the same error.