Skip to content

Commit

Permalink
Avoid onError call if context is lost after finalization (visgl#5992)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored Jul 21, 2021
1 parent de8136d commit 8b71107
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/core/src/lib/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8b71107

Please sign in to comment.