Skip to content

Commit

Permalink
fix(terminal): fallback to canvas if webgl renderer incompatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Clem-Fern committed Oct 5, 2023
1 parent 83c0892 commit 7d5128a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tabby-terminal/src/api/baseTerminalTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,26 @@ export class BaseTerminalTabComponent<P extends BaseTerminalProfile> 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
Expand Down

0 comments on commit 7d5128a

Please sign in to comment.