diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18d34831..43dae881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,7 +66,7 @@ jobs: ./addons/addon-webgl/out/* \ ./addons/addon-webgl/out-*st/* - name: Upload artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build-artifacts path: compressed-build.zip @@ -108,7 +108,7 @@ jobs: run: | yarn --frozen-lockfile yarn install-addons - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: build-artifacts - name: Unzip artifacts @@ -150,7 +150,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} job: build - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: build-artifacts - name: Unzip artifacts @@ -191,7 +191,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} job: build - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: build-artifacts - name: Unzip artifacts @@ -249,7 +249,7 @@ jobs: yarn install-addons - name: Install playwright run: npx playwright install - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: build-artifacts - name: Unzip artifacts diff --git a/addons/addon-webgl/src/WebglRenderer.ts b/addons/addon-webgl/src/WebglRenderer.ts index 398594d9..576cdad5 100644 --- a/addons/addon-webgl/src/WebglRenderer.ts +++ b/addons/addon-webgl/src/WebglRenderer.ts @@ -76,6 +76,20 @@ export class WebglRenderer extends Disposable implements IRenderer { ) { super(); + // IMPORTANT: Canvas initialization and fetching of the context must be first in order to + // prevent possible listeners leaking and continuing to operate after the WebglRenderer has been + // discarded. + this._canvas = this._coreBrowserService.mainDocument.createElement('canvas'); + const contextAttributes = { + antialias: false, + depth: false, + preserveDrawingBuffer + }; + this._gl = this._canvas.getContext('webgl2', contextAttributes) as IWebGL2RenderingContext; + if (!this._gl) { + throw new Error('WebGL2 not supported ' + this._gl); + } + this._register(this._themeService.onChangeColors(() => this._handleColorChange())); 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 { this._updateCursorBlink(); this._register(_optionsService.onOptionChange(() => this._handleOptionsChanged())); - this._canvas = this._coreBrowserService.mainDocument.createElement('canvas'); - - const contextAttributes = { - antialias: false, - depth: false, - preserveDrawingBuffer - }; - this._gl = this._canvas.getContext('webgl2', contextAttributes) as IWebGL2RenderingContext; - if (!this._gl) { - throw new Error('WebGL2 not supported ' + this._gl); - } - this._deviceMaxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE); this._register(addDisposableListener(this._canvas, 'webglcontextlost', (e) => {