From a8d43eb2ec9d0aca8aa21cf34931c5ab0357a5a8 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 7 Feb 2025 05:58:28 -0800 Subject: [PATCH 1/3] Fix issue where listeners remain after WebglRenderer throws See microsoft/vscode#239838 --- addons/addon-webgl/src/WebglRenderer.ts | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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) => { From 9a3d1c6de19601b687c81ff58e7a801f8635e805 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 7 Feb 2025 06:07:47 -0800 Subject: [PATCH 2/3] Bump upload-artifact --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18d34831..3290164f 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 From 1c98c525359360cac4d65d6ee0ac22eee5d1f1f0 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 7 Feb 2025 06:11:47 -0800 Subject: [PATCH 3/3] Bump download-artifact --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3290164f..43dae881 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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