Skip to content

Commit c82f011

Browse files
authored
Merge pull request #1888 from DhivinX/fix/lose-context
fix: lose unused WebGL context after Canvas destroy
2 parents fd6d118 + e75ea7a commit c82f011

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/viewer/scene/canvas/Canvas.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
import {math} from '../math/math.js';
3-
import {Component} from '../Component.js';
4-
import {Spinner} from './Spinner.js';
2+
import { Component } from '../Component.js';
3+
import { math } from '../math/math.js';
4+
import { Spinner } from './Spinner.js';
55

66
const WEBGL_CONTEXT_NAMES = [
77
"webgl2",
@@ -482,9 +482,12 @@ class Canvas extends Component {
482482
// Memory leak avoidance
483483
this.canvas.removeEventListener("webglcontextlost", this._webglcontextlostListener);
484484
this.canvas.removeEventListener("webglcontextrestored", this._webglcontextrestoredListener);
485+
486+
this.gl.getExtension("WEBGL_lose_context").loseContext();
485487
this.gl = null;
488+
486489
super.destroy();
487490
}
488491
}
489492

490-
export {Canvas};
493+
export { Canvas };

0 commit comments

Comments
 (0)