Tweak handling of _contextRestorationTimeout
This commit is contained in:
@@ -53,6 +53,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
|
|
||||||
private _core: ITerminal;
|
private _core: ITerminal;
|
||||||
private _isAttached: boolean;
|
private _isAttached: boolean;
|
||||||
|
private _contextRestorationTimeout: number | undefined;
|
||||||
|
|
||||||
private _onChangeTextureAtlas = new EventEmitter<HTMLCanvasElement>();
|
private _onChangeTextureAtlas = new EventEmitter<HTMLCanvasElement>();
|
||||||
public get onChangeTextureAtlas(): IEvent<HTMLCanvasElement> { return this._onChangeTextureAtlas.event; }
|
public get onChangeTextureAtlas(): IEvent<HTMLCanvasElement> { return this._onChangeTextureAtlas.event; }
|
||||||
@@ -62,8 +63,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
private _onContextLoss = new EventEmitter<void>();
|
private _onContextLoss = new EventEmitter<void>();
|
||||||
public get onContextLoss(): IEvent<void> { return this._onContextLoss.event; }
|
public get onContextLoss(): IEvent<void> { return this._onContextLoss.event; }
|
||||||
|
|
||||||
private _contextRestorationTimeout: number | undefined;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _terminal: Terminal,
|
private _terminal: Terminal,
|
||||||
private _colors: IColorSet,
|
private _colors: IColorSet,
|
||||||
@@ -117,16 +116,15 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
// Wait a few seconds to see if the 'webglcontextrestored' event is fired.
|
// Wait a few seconds to see if the 'webglcontextrestored' event is fired.
|
||||||
// If not, dispatch the onContextLoss notification to observers.
|
// If not, dispatch the onContextLoss notification to observers.
|
||||||
this._contextRestorationTimeout = setTimeout(() => {
|
this._contextRestorationTimeout = setTimeout(() => {
|
||||||
if (this._contextRestorationTimeout !== 0) {
|
this._contextRestorationTimeout = undefined;
|
||||||
console.log('webgl context not restored; firing onContextLoss');
|
console.warn('webgl context not restored; firing onContextLoss');
|
||||||
this._onContextLoss.fire(e);
|
this._onContextLoss.fire(e);
|
||||||
}
|
|
||||||
}, 3000 /* ms */);
|
}, 3000 /* ms */);
|
||||||
}));
|
}));
|
||||||
this.register(addDisposableDomListener(this._canvas, 'webglcontextrestored', (e) => {
|
this.register(addDisposableDomListener(this._canvas, 'webglcontextrestored', (e) => {
|
||||||
console.log('webglcontextrestored event received');
|
console.warn('webglcontextrestored event received');
|
||||||
clearTimeout(this._contextRestorationTimeout);
|
clearTimeout(this._contextRestorationTimeout);
|
||||||
this._contextRestorationTimeout = 0;
|
this._contextRestorationTimeout = undefined;
|
||||||
// The texture atlas and glyph renderer must be fully reinitialized
|
// The texture atlas and glyph renderer must be fully reinitialized
|
||||||
// because their contents have been lost.
|
// because their contents have been lost.
|
||||||
removeTerminalFromCache(this._terminal);
|
removeTerminalFromCache(this._terminal);
|
||||||
|
|||||||
Reference in New Issue
Block a user