Prayer Progress released mid-start no longer reports a failed map

Prayer Progress is a heavy gallery tab: switching away empties its slot. If the map
is still starting, initializeMap returns silently (useMapInstance's liveness
checks) and leaves map.value null. onMounted then logged "[doxa-simple-map] Map
failed to initialize, check token and container": a console error that blamed
the token for a tab switch.

Measured on development's tip, served from its committed tree, on the shared
browser, a phone in Arabic (pp-fastswitch.mjs): switched away 150 and 500 ms after
selecting the tab, 2 runs in 10 logged it. The control runs, switched away after a
full start or never switched away, logged nothing.

Same shape as the research map's quiet cancel (0c263fb60): when the map's
container is gone or detached, both failure paths return quietly. A mounted pane
that really fails still logs.
This commit is contained in:
Doxa Maps 2026-09-29 23:08:17 +00:00
parent f3b1566c76
commit e4b5a3d1b1

View file

@ -1356,9 +1356,18 @@ onMounted(async () => {
})
// 2. Initialize map (returns before 'load' fires)
// ★ A PANE RELEASED WHILE ITS MAP IS STILL STARTING IS A CANCEL, NOT A FAILURE. This map is a heavy
// gallery tab: switching away empties its slot. initializeMap then returns SILENTLY (useMapInstance's
// liveness checks) and leaves map.value null, which this reported as "Map failed to initialize —
// check token and container": a console ERROR blaming the token for a tab switch (measured
// 2026-09-29, a phone in Arabic, switched away 150 and 500 ms in: 2 runs in 10; 0 when the map was
// left to start). Nobody is waiting for this map any more, so return quietly. A mounted pane that
// really fails still logs.
const released = () => !mapContainer.value || !mapContainer.value.isConnected
try {
await initializeMap()
} catch (err) {
if (released()) return
// `new mapboxgl.Map()` throws outright when the device has no WebGL context.
console.error('[doxa-simple-map] Map failed to initialize —', err)
mapError.value = String(err?.message || err)
@ -1367,6 +1376,7 @@ onMounted(async () => {
unwrapMap()
if (!map.value) {
if (released()) return
console.error('[doxa-simple-map] Map failed to initialize — check token and container')
mapError.value = t('simpleMap.initFailed')
return