From 162d3634135843d173cb574fa63b9d6a0ba9acc6 Mon Sep 17 00:00:00 2001 From: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com> Date: Mon, 18 Sep 2023 13:02:00 +0100 Subject: [PATCH] Fix to restoring lost context on WebGL related to very recent backbuffer refactoring (#5643) Co-authored-by: Martin Valigursky --- src/platform/graphics/webgl/webgl-graphics-device.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/graphics/webgl/webgl-graphics-device.js b/src/platform/graphics/webgl/webgl-graphics-device.js index c51042ba02a..c2953a8cc9e 100644 --- a/src/platform/graphics/webgl/webgl-graphics-device.js +++ b/src/platform/graphics/webgl/webgl-graphics-device.js @@ -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'); }; @@ -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();