@xterm/addon-webgl 0.19.0-beta.96 → 0.19.0-beta.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xterm/addon-webgl",
3
- "version": "0.19.0-beta.96",
3
+ "version": "0.19.0-beta.97",
4
4
  "author": {
5
5
  "name": "The xterm.js authors",
6
6
  "url": "https://xtermjs.org/"
@@ -24,7 +24,7 @@
24
24
  "start": "node ../../demo/start"
25
25
  },
26
26
  "peerDependencies": {
27
- "@xterm/xterm": "^5.6.0-beta.96"
27
+ "@xterm/xterm": "^5.6.0-beta.97"
28
28
  },
29
- "commit": "d81b25c3bf6c0e3352c175705f460aa39df6e374"
29
+ "commit": "a7a941ce788351535abb0fa3aaef230923163ea4"
30
30
  }
@@ -76,6 +76,20 @@ export class WebglRenderer extends Disposable implements IRenderer {
76
76
  ) {
77
77
  super();
78
78
 
79
+ // IMPORTANT: Canvas initialization and fetching of the context must be first in order to
80
+ // prevent possible listeners leaking and continuing to operate after the WebglRenderer has been
81
+ // discarded.
82
+ this._canvas = this._coreBrowserService.mainDocument.createElement('canvas');
83
+ const contextAttributes = {
84
+ antialias: false,
85
+ depth: false,
86
+ preserveDrawingBuffer
87
+ };
88
+ this._gl = this._canvas.getContext('webgl2', contextAttributes) as IWebGL2RenderingContext;
89
+ if (!this._gl) {
90
+ throw new Error('WebGL2 not supported ' + this._gl);
91
+ }
92
+
79
93
  this._register(this._themeService.onChangeColors(() => this._handleColorChange()));
80
94
 
81
95
  this._cellColorResolver = new CellColorResolver(this._terminal, this._optionsService, this._model.selection, this._decorationService, this._coreBrowserService, this._themeService);
@@ -91,18 +105,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
91
105
  this._updateCursorBlink();
92
106
  this._register(_optionsService.onOptionChange(() => this._handleOptionsChanged()));
93
107
 
94
- this._canvas = this._coreBrowserService.mainDocument.createElement('canvas');
95
-
96
- const contextAttributes = {
97
- antialias: false,
98
- depth: false,
99
- preserveDrawingBuffer
100
- };
101
- this._gl = this._canvas.getContext('webgl2', contextAttributes) as IWebGL2RenderingContext;
102
- if (!this._gl) {
103
- throw new Error('WebGL2 not supported ' + this._gl);
104
- }
105
-
106
108
  this._deviceMaxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
107
109
 
108
110
  this._register(addDisposableListener(this._canvas, 'webglcontextlost', (e) => {