From 7d87ec4c4733028c8e9b11b7c5e8a0e413e6e133 Mon Sep 17 00:00:00 2001 From: ltadeu6 Date: Sun, 7 Jun 2026 13:52:20 -0300 Subject: [PATCH] fix: retry canvas init until WebEngine reports valid dimensions qdbus6 refreshCurrentShell sometimes reloads the page before the WebEngine has settled, leaving innerWidth/Height at 0. Canvas stays 0x0 and the rAF loops draw nothing. initCanvases() now polls every 80ms until dimensions are valid before calling resizeCanvas/resizeFloor. Co-Authored-By: Claude Sonnet 4.6 --- plugin/contents/ui/dancer.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugin/contents/ui/dancer.html b/plugin/contents/ui/dancer.html index 536ee35..c85ce4b 100644 --- a/plugin/contents/ui/dancer.html +++ b/plugin/contents/ui/dancer.html @@ -951,8 +951,6 @@ function drawStars(ts) { } window.addEventListener('resize', resizeCanvas); -resizeCanvas(); -requestAnimationFrame(drawStars); /* ============================================================ FLOOR CANVAS — perspective grid with true vanishing point @@ -1027,8 +1025,19 @@ function drawFloor(ts) { } window.addEventListener('resize', resizeFloor); -resizeFloor(); -requestAnimationFrame(drawFloor); + +// WebEngine sometimes reports innerWidth=0 on first load — retry until valid. +function initCanvases() { + if (window.innerWidth > 0 && window.innerHeight > 0) { + resizeCanvas(); + resizeFloor(); + requestAnimationFrame(drawStars); + requestAnimationFrame(drawFloor); + } else { + setTimeout(initCanvases, 80); + } +} +initCanvases(); /* ============================================================