From: Chris Duncan Date: Thu, 2 Apr 2026 20:57:06 +0000 (-0700) Subject: Add context create error listener and improve messaging. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=73dd9f452c10303935e37bf8771f732587d30bb4;p=nano-pow.git Add context create error listener and improve messaging. --- 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)