diff --git a/modules/core/src/lib/deck.js b/modules/core/src/lib/deck.js index f6dcaeeb0d6..1f53d3fd895 100644 --- a/modules/core/src/lib/deck.js +++ b/modules/core/src/lib/deck.js @@ -508,7 +508,7 @@ export default class Deck { ...opts, canvas: this.canvas, debug, - onContextLost: _ => onError?.(new Error(`WebGL context is lost`)) + onContextLost: () => this._onContextLost() }), onInitialize: context => this._setGLContext(context.gl), onRender: this._onRenderFrame.bind(this), @@ -536,6 +536,13 @@ export default class Deck { return views; } + _onContextLost() { + const {onError} = this.props; + if (this.animationLoop && onError) { + onError(new Error(`WebGL context is lost`)); + } + } + // The `pointermove` event may fire multiple times in between two animation frames, // it's a waste of time to run picking without rerender. Instead we save the last pick // request and only do it once on the next animation frame.