From 66365e5ac81d25d338e4c3c1ad84dd9984ccaa9b Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 2 Apr 2026 00:23:05 -0700 Subject: [PATCH] Fix max viewport dimensions. Use MDN-recommended fallback max viewport dimensions if they return null, currently due to iOS Safari regression. Wrap entire test page script in try-catch to log additional errors. --- src/lib/generate/webgl/index.ts | 5 +++-- test/index.html | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/lib/generate/webgl/index.ts b/src/lib/generate/webgl/index.ts index 9dffe92..2340749 100644 --- a/src/lib/generate/webgl/index.ts +++ b/src/lib/generate/webgl/index.ts @@ -91,9 +91,10 @@ function createCanvas (size: number): void { if (context == null) throw new Error('WebGL 2 is required') gl = context + const MAX_VIEWPORT_DIMS = gl.getParameter(gl.MAX_VIEWPORT_DIMS) ?? [0x1000, 0x1000] LOG: logger.log('NanoPow WebGL createCanvas', 'requested size', size) - LOG: logger.log('NanoPow WebGL createCanvas', 'MAX_VIEWPORT_DIMS', ...gl.getParameter(gl.MAX_VIEWPORT_DIMS)) - size = Math.min(size, ...gl.getParameter(gl.MAX_VIEWPORT_DIMS)) + LOG: logger.log('NanoPow WebGL createCanvas', 'MAX_VIEWPORT_DIMS', MAX_VIEWPORT_DIMS) + size = Math.min(size, ...MAX_VIEWPORT_DIMS) size = Math.floor(size / 0x100) * 0x100 canvas.height = canvas.width = size LOG: logger.log('NanoPow WebGL createCanvas', 'canvas size', canvas.height, canvas.width) diff --git a/test/index.html b/test/index.html index 3540d2b..98d48c0 100644 --- a/test/index.html +++ b/test/index.html @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-3.0-or-later