This is the proper fix for microsoft/vscode#162996, after a bunch of investigation we found that this is causing the problem: VS Code clears the texture atlas on OS resume to fix an issue where the texture could be corrupted. This calls clearTextureAtlas twice which should be fine, but it's not because inside WebglRenderer.clear we're calling updateModel which is meant to only ever be called in an animation frame. This calls potentially both renderers to have stale views of the texture atlas for those rows and our perf caching of cells (the main purpose of the model) doesn't know it's stale. Co-Authored-By: Megan Rogge <merogge@microsoft.com>
xterm-addon-webgl
An addon for xterm.js that enables a WebGL2-based renderer. This addon requires xterm.js v4+.
Install
npm install --save xterm-addon-webgl
Usage
import { Terminal } from 'xterm';
import { WebglAddon } from 'xterm-addon-webgl';
const terminal = new Terminal();
terminal.open(element);
terminal.loadAddon(new WebglAddon());
See the full API for more advanced usage.
Handling Context Loss
The browser may drop WebGL contexts for various reasons like OOM or after the system has been suspended. There is an API exposed that fires the webglcontextlost event fired on the canvas so embedders can handle it however they wish. An easy, but suboptimal way, to handle this is by disposing of WebglAddon when the event fires:
const terminal = new Terminal();
const addon = new WebglAddon();
addon.onContextLoss(e => {
addon.dispose();
});
terminal.loadAddon(addon);
Read more about handling WebGL context losses on the Khronos wiki.
See also
- xterm-addon-canvas A renderer for xterm.js that uses a 2d canvas that can be used as a fallback when WebGL is not available