From 28c5d64a2a4c2476b3abfb98fcd7b1623cd2dff2 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Sun, 16 Aug 2026 18:56:50 +0300 Subject: [PATCH] Improve game initialization by ensuring the stage is visible before Pixi.js initialization; synchronize renderer on menu to game switch for better rendering performance. --- src/TheLivingWorld.Web/src/main.ts | 5 ++++- src/TheLivingWorld.Web/src/map/mapView.ts | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TheLivingWorld.Web/src/main.ts b/src/TheLivingWorld.Web/src/main.ts index 1585f0c..12ce373 100644 --- a/src/TheLivingWorld.Web/src/main.ts +++ b/src/TheLivingWorld.Web/src/main.ts @@ -139,6 +139,9 @@ async function ensureMap(): Promise { async function openWorld(id: string): Promise { try { setStatus('Loading map…', 'busy'); + // Stage must be visible before Pixi init / camera.fit — a hidden host measures as 0×0 and + // leaves the canvas stuck as a thin strip. + showGame(); await ensureMap(); const map = await api.getMap(id); @@ -148,10 +151,10 @@ async function openWorld(id: string): Promise { view.showWorld(map); elements.worldTitle.textContent = map.name; elements.hud.textContent = ''; - showGame(); setStatus(''); await refreshWorldList(); } catch (error) { + showMenu(); setStatus(`Could not open world: ${message(error)}`, 'error'); } } diff --git a/src/TheLivingWorld.Web/src/map/mapView.ts b/src/TheLivingWorld.Web/src/map/mapView.ts index dc8fe1f..5ce7da1 100644 --- a/src/TheLivingWorld.Web/src/map/mapView.ts +++ b/src/TheLivingWorld.Web/src/map/mapView.ts @@ -98,6 +98,9 @@ export class MapView { this.labels.clear(); this.worldSizeMeters = map.sizeMeters; + // Host may have just become visible after a menu → game switch; sync the renderer before fitting. + this.app.resize(); + this.paintBackground(); this.camera.fit(map.sizeMeters, this.viewport); this.chunks.setWorld(map.id, map.chunks);