Skip to content

Commit

Permalink
fallback to canvas renderer on webgl context loss
Browse files Browse the repository at this point in the history
  • Loading branch information
LabhanshAgrawal authored Jun 18, 2023
1 parent bb0c98f commit 7cb40b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/components/term.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit 7cb40b9

Please sign in to comment.