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 <noreply@anthropic.com>
This commit is contained in:
parent
347b3729c8
commit
7d87ec4c47
1 changed files with 13 additions and 4 deletions
|
|
@ -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();
|
||||
|
||||
|
||||
/* ============================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue