From 7d5128a8ce373793a930a4b3167920a0b8bd9f00 Mon Sep 17 00:00:00 2001 From: Clem Fern Date: Thu, 5 Oct 2023 22:49:42 +0200 Subject: [PATCH] fix(terminal): fallback to canvas if webgl renderer incompatible ref Eugeny/tabby#8884 ref https://bugs.chromium.org/p/chromium/issues/detail?id=1476475 --- .../src/api/baseTerminalTab.component.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index c310937fd7..06c4f43a80 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -340,7 +340,26 @@ export class BaseTerminalTabComponent

extends Bas this.configure() }) - const cls: new (..._) => Frontend = { + // Check if the the WebGL renderer is compatible with xterm.js: + // - https://github.com/Eugeny/tabby/issues/8884 + // - https://github.com/microsoft/vscode/issues/190195 + // - https://github.com/xtermjs/xterm.js/issues/4665 + // - https://bugs.chromium.org/p/chromium/issues/detail?id=1476475 + // + // Inspired by https://github.com/microsoft/vscode/pull/191795 + + let enable8884Workarround = false + const checkCanvas = document.createElement('canvas') + const checkGl = checkCanvas.getContext('webgl2') + const debugInfo = checkGl?.getExtension('WEBGL_debug_renderer_info') + if (checkGl && debugInfo) { + const renderer = checkGl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) + if (renderer.startsWith('ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero)')) { + enable8884Workarround = true + } + } + + const cls: new (..._) => Frontend = enable8884Workarround ? XTermFrontend : { xterm: XTermFrontend, 'xterm-webgl': XTermWebGLFrontend, }[this.config.store.terminal.frontend] ?? XTermFrontend