fallback to canvas renderer on webgl context loss

This commit is contained in:
Labhansh Agrawal 2023-06-18 20:01:02 +05:30 committed by GitHub
parent bb0c98f0f6
commit 7cb40b952d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -215,12 +215,18 @@ export default class Term extends React.PureComponent<
this.term.open(this.termRef);
if (useWebGL) {
this.term.loadAddon(new WebglAddon());
const webglAddon = new WebglAddon();
this.term.loadAddon(webglAddon);
webglAddon.onContextLoss(() => {
console.warn('WebGL context lost. Falling back to canvas-based rendering.');
webglAddon.dispose();
this.term.loadAddon(new CanvasAddon());
});
} else {
this.term.loadAddon(new CanvasAddon());
}
if (props.disableLigatures !== true) {
if (props.disableLigatures !== true && !useWebGL) {
this.term.loadAddon(new LigaturesAddon());
}