From 73dd9f452c10303935e37bf8771f732587d30bb4 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Thu, 2 Apr 2026 13:57:06 -0700 Subject: [PATCH] Add context create error listener and improve messaging. --- test/index.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/index.html b/test/index.html index 0ed6166..65f0cf4 100644 --- a/test/index.html +++ b/test/index.html @@ -28,18 +28,21 @@ SPDX-License-Identifier: GPL-3.0-or-later let isContextLost = 0 const glSize = (canvas => { + canvas.addEventListener('webglcontextcreationerror', ev => { + console.log('NanoPow test page WebGL context create error during glSize()', ev.statusMessage) + }) canvas.addEventListener('webglcontextlost', ev => { // Set up 10s timeout to prevent long-running restoration isContextLost = window.setTimeout(() => { throw new Error('NanoPow could not restore WebGL context.') }, 10_000) ev.preventDefault() - console.log('NanoPow test page glSize', 'WebGL context lost.') + console.log('NanoPow test page WebGL context lost during glSize()', ev.statusMessage) }) canvas.addEventListener('webglcontextrestored', ev => { window.clearTimeout(isContextLost) isContextLost = 0 - console.log('NanoPow test page glSize', 'WebGL context restored.') + console.log('NanoPow test page WebGL context restored during glSize()', ev.statusMessage) }) const gl = canvas.getContext('webgl2') const MAX_VIEWPORT_DIMS = gl.getParameter(gl.MAX_VIEWPORT_DIMS) -- 2.47.3