From c9aca2ed50971ecaa58cc1ca004facc303e78cdc Mon Sep 17 00:00:00 2001 From: vini Date: Sun, 19 Jul 2026 14:18:33 -0300 Subject: [PATCH] Limit sky transition buffer memory --- plugin/contents/ui/dancer.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugin/contents/ui/dancer.html b/plugin/contents/ui/dancer.html index 8fe137a..169f8bc 100644 --- a/plugin/contents/ui/dancer.html +++ b/plugin/contents/ui/dancer.html @@ -1590,13 +1590,14 @@ let lastProjMs = -Infinity; function projectSky() { const W = canvas.width, H = canvas.height; if (!W || !H) return; - if (renderCanvas.width !== W || renderCanvas.height !== H) { + const horizonPx = H * HORIZON_F; + const bufferH = Math.ceil(Math.min(H, horizonPx * 1.05)); + if (renderCanvas.width !== W || renderCanvas.height !== bufferH) { renderCanvas.width = W; - renderCanvas.height = H; + renderCanvas.height = bufferH; } const bctx = renderCanvas.getContext('2d'); - bctx.clearRect(0, 0, W, H); - const horizonPx = H * HORIZON_F; + bctx.clearRect(0, 0, W, bufferH); const lst = localSiderealDeg(Date.now() + window.__skyTimeOffset); const glareOn = !document.body.classList.contains('balada') && !document.body.classList.contains('chuva'); @@ -1687,8 +1688,8 @@ function drawStars(ts) { ctx.clearRect(0, 0, canvas.width, canvas.height); const transition = Math.max(0, Math.min(1, (ts - skyTransitionStart) / SKY_TRANSITION_MS)); - if (transition < 1 && previousBaseCanvas.width === canvas.width && - previousBaseCanvas.height === canvas.height) { + if (transition < 1 && previousBaseCanvas.width === baseCanvas.width && + previousBaseCanvas.height === baseCanvas.height) { const blend = transition * transition * (3 - 2 * transition); ctx.globalAlpha = 1 - blend; ctx.drawImage(previousBaseCanvas, 0, 0);