Skip to content

Commit f309aff

Browse files
authored
Tweak handling of _contextRestorationTimeout
1 parent 9459553 commit f309aff

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

addons/xterm-addon-webgl/src/WebglRenderer.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
5353

5454
private _core: ITerminal;
5555
private _isAttached: boolean;
56+
private _contextRestorationTimeout: number | undefined;
5657

5758
private _onChangeTextureAtlas = new EventEmitter<HTMLCanvasElement>();
5859
public get onChangeTextureAtlas(): IEvent<HTMLCanvasElement> { return this._onChangeTextureAtlas.event; }
@@ -62,8 +63,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
6263
private _onContextLoss = new EventEmitter<void>();
6364
public get onContextLoss(): IEvent<void> { return this._onContextLoss.event; }
6465

65-
private _contextRestorationTimeout: number | undefined;
66-
6766
constructor(
6867
private _terminal: Terminal,
6968
private _colors: IColorSet,
@@ -117,16 +116,15 @@ export class WebglRenderer extends Disposable implements IRenderer {
117116
// Wait a few seconds to see if the 'webglcontextrestored' event is fired.
118117
// If not, dispatch the onContextLoss notification to observers.
119118
this._contextRestorationTimeout = setTimeout(() => {
120-
if (this._contextRestorationTimeout !== 0) {
121-
console.log('webgl context not restored; firing onContextLoss');
122-
this._onContextLoss.fire(e);
123-
}
119+
this._contextRestorationTimeout = undefined;
120+
console.warn('webgl context not restored; firing onContextLoss');
121+
this._onContextLoss.fire(e);
124122
}, 3000 /* ms */);
125123
}));
126124
this.register(addDisposableDomListener(this._canvas, 'webglcontextrestored', (e) => {
127-
console.log('webglcontextrestored event received');
125+
console.warn('webglcontextrestored event received');
128126
clearTimeout(this._contextRestorationTimeout);
129-
this._contextRestorationTimeout = 0;
127+
this._contextRestorationTimeout = undefined;
130128
// The texture atlas and glyph renderer must be fully reinitialized
131129
// because their contents have been lost.
132130
removeTerminalFromCache(this._terminal);

0 commit comments

Comments
 (0)