From df3e0c86d62b554e2b8c55543b41b7533760fdc6 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 20:04:46 -0700 Subject: [PATCH 1/3] fall back to dom if webgl loses context --- .../workbench/contrib/terminal/browser/terminalInstance.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 5ace875fb3f417..567cc178e5782e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1313,6 +1313,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._webglAddon = new Addon(); try { this._xterm.loadAddon(this._webglAddon); + this._webglAddon.onContextLoss((e => { + (e as any).preventDefault(); + this._storageService.store(SUGGESTED_RENDERER_TYPE, 'dom', StorageScope.GLOBAL, StorageTarget.MACHINE); + this._safeSetOption('rendererType', 'dom'); + this._disposeOfWebglRenderer(); + })); this._storageService.store(SUGGESTED_RENDERER_TYPE, 'auto', StorageScope.GLOBAL, StorageTarget.MACHINE); } catch (e) { this._logService.warn(`Webgl could not be loaded. Falling back to the canvas renderer type.`, e); From d2c3ec9f65fb0b169895b2f146f07ee7f31da94c Mon Sep 17 00:00:00 2001 From: meganrogge Date: Thu, 1 Apr 2021 20:36:57 -0700 Subject: [PATCH 2/3] update config when context loss occurs --- .../contrib/terminal/browser/terminalInstance.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 567cc178e5782e..a0ed289cec2469 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -230,7 +230,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._instanceId = TerminalInstance._instanceIdCounter++; this.hasHadInput = false; - this._titleReadyPromise = new Promise(c => { this._titleReadyComplete = c; }); @@ -1313,12 +1312,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this._webglAddon = new Addon(); try { this._xterm.loadAddon(this._webglAddon); - this._webglAddon.onContextLoss((e => { - (e as any).preventDefault(); + this._webglAddon.onContextLoss(() => { this._storageService.store(SUGGESTED_RENDERER_TYPE, 'dom', StorageScope.GLOBAL, StorageTarget.MACHINE); - this._safeSetOption('rendererType', 'dom'); + this.updateConfig(); this._disposeOfWebglRenderer(); - })); + }); this._storageService.store(SUGGESTED_RENDERER_TYPE, 'auto', StorageScope.GLOBAL, StorageTarget.MACHINE); } catch (e) { this._logService.warn(`Webgl could not be loaded. Falling back to the canvas renderer type.`, e); From d9473524367d70e4b97b4b0766fb61fba9350dc1 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Fri, 2 Apr 2021 10:13:26 -0700 Subject: [PATCH 3/3] don't store suggested renderer type on context loss --- src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index a0ed289cec2469..cd7c671dddb930 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1313,9 +1313,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { try { this._xterm.loadAddon(this._webglAddon); this._webglAddon.onContextLoss(() => { - this._storageService.store(SUGGESTED_RENDERER_TYPE, 'dom', StorageScope.GLOBAL, StorageTarget.MACHINE); - this.updateConfig(); + this._logService.info(`Webgl lost context, disposing of webgl renderer`); this._disposeOfWebglRenderer(); + this._safeSetOption('rendererType', 'dom'); }); this._storageService.store(SUGGESTED_RENDERER_TYPE, 'auto', StorageScope.GLOBAL, StorageTarget.MACHINE); } catch (e) {