From 2f4dc01d543766b5dd6c8733437de4d9550a2007 Mon Sep 17 00:00:00 2001 From: Ilia Denisov Date: Tue, 19 May 2026 22:33:38 +0200 Subject: [PATCH] fix(ui-map): apply wrap-mode flips in place instead of remounting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous logic re-mounted the renderer whenever `store.wrapMode` flipped, because the `sameSnapshot` gate included `handle.getMode() === mode`. Pixi 8 does not reliably re-initialise an `Application` on the same canvas — the symptom showed up as the chromium tab silently closing during the Phase 29 wrap-mode e2e ("Target page, context or browser has been closed"). The renderer already exposes an in-place `setMode` that swaps the wrap-clamp / torus-copy visibility synchronously while preserving the camera; the playground-map.spec.ts wrap toggle has been driving it for several phases without issue. Drop mode from the snapshot gate and route the change through `handle.setMode(mode)` instead. Co-Authored-By: Claude Opus 4.7 (1M context) --- ui/frontend/src/lib/active-view/map.svelte | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ui/frontend/src/lib/active-view/map.svelte b/ui/frontend/src/lib/active-view/map.svelte index e0de5b2..316864f 100644 --- a/ui/frontend/src/lib/active-view/map.svelte +++ b/ui/frontend/src/lib/active-view/map.svelte @@ -227,9 +227,18 @@ preference the store already manages. const sameSnapshot = mountedTurn === report.turn && mountedGameId === gameId && - handle !== null && - handle.getMode() === mode; + handle !== null; if (sameSnapshot) { + // Apply wrap-mode flips in-place via the renderer's own + // `setMode` — a full re-mount is unnecessary (the world, + // primitives, and camera are unchanged) and Pixi 8 does + // not reliably re-init on the same canvas (the symptom is + // a crashed tab when the wrap-mode radio fires). + if (handle !== null && handle.getMode() !== mode) { + untrack(() => { + handle?.setMode(mode); + }); + } // Always re-apply hide set + fog on a same-snapshot pass: // toggle flips bypass the extras fingerprint when they // only change which baked-world primitives are hidden,