From db4c613b9e2c17ff5f31455c46712a26d32d5bb3 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 16 Dec 2022 11:39:32 +1100 Subject: [PATCH] Fix infinite recursion on resize In Chromium 108.0.5359.124 I saw infinite recursion in maybeResize/resize/onBeforeFrame. So I added a recursion guard to maybeResize. --- src/views/application.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/application.tsx b/src/views/application.tsx index ee1c22506..bda93283b 100644 --- a/src/views/application.tsx +++ b/src/views/application.tsx @@ -67,6 +67,7 @@ interface GLCanvasProps { } export class GLCanvas extends StatelessComponent { private canvas: HTMLCanvasElement | null = null + private inResize = false private ref = (canvas: Element | null) => { if (canvas instanceof HTMLCanvasElement) { @@ -90,6 +91,7 @@ export class GLCanvas extends StatelessComponent { private maybeResize = () => { if (!this.container) return if (!this.props.canvasContext) return + if (this.inResize) return let {width, height} = this.container.getBoundingClientRect() @@ -98,12 +100,14 @@ export class GLCanvas extends StatelessComponent { const widthInPixels = width * window.devicePixelRatio const heightInPixels = height * window.devicePixelRatio + this.inResize = true this.props.canvasContext.gl.resize( widthInPixels, heightInPixels, widthInAppUnits, heightInAppUnits, ) + this.inResize = false } onWindowResize = () => {