Skip to content

Commit

Permalink
Fix to restoring lost context on WebGL related to very recent backbuf…
Browse files Browse the repository at this point in the history
…fer refactoring (#5643)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Sep 18, 2023
1 parent 42313e2 commit 162d363
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ class WebglGraphicsDevice extends GraphicsDevice {

this._contextRestoredHandler = () => {
Debug.log('pc.GraphicsDevice: WebGL context restored.');
this.restoreContext();
this.contextLost = false;
this.restoreContext();
this.fire('devicerestored');
};

Expand Down Expand Up @@ -1165,6 +1165,10 @@ class WebglGraphicsDevice extends GraphicsDevice {
* @ignore
*/
loseContext() {

// force the backbuffer to be recreated on restore
this.backBufferSize.set(-1, -1);

// release shaders
for (const shader of this.shaders) {
shader.loseContext();
Expand Down

0 comments on commit 162d363

Please sign in to comment.