From 7cb40b952d8cc1bf86970f179e2837b2015ada05 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Sun, 18 Jun 2023 20:01:02 +0530 Subject: [PATCH] fallback to canvas renderer on webgl context loss --- lib/components/term.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/components/term.tsx b/lib/components/term.tsx index 4df1bfb5..43d37961 100644 --- a/lib/components/term.tsx +++ b/lib/components/term.tsx @@ -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()); }