From 691cb0cd79b0a0b9edb213a482fab6cc92c5a214 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Tue, 10 Nov 2026 18:29:47 -0800 Subject: [PATCH] A stack kept after a failed photoreal switch still falls back on tile failures - When showing the photoreal base fails and the stack before it stays, its tile-failure listener is bound again for the switch that kept it, so Esri's OSM fallback still runs. - The Cockpit test of a ride handed to another aircraft checks that the follow's change adopted it (the Cockpit took the camera). --- src/maps/controller.js | 18 +++++++++++++++++- src/maps/globeEngine.test.mjs | 22 ++++++++++++++++++++++ src/ui/cockpitEntryGate.test.mjs | 5 ++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/maps/controller.js b/src/maps/controller.js index 838e5f304..5b1043142 100644 --- a/src/maps/controller.js +++ b/src/maps/controller.js @@ -302,7 +302,23 @@ export class MapSourceController { if (this._engine.tilesetReady) { this._showTileset(tileset); const ready = this._engine.tilesetReady(tileset); - if (ready) await ready; + if (ready) + try { + await ready; + } catch (error) { + // The stack before it stays: its tile failures still fall back, + // heard for this switch. + if ( + gen === this._switchGen && + this._imageryLayer && + this._activeResolution + ) { + this._removeImageryErrorListener?.(); + this._removeImageryErrorListener = null; + this._watchProvider(this._activeResolution, gen); + } + throw error; + } if (gen !== this._switchGen) return; } this._removeImageryLayer(); diff --git a/src/maps/globeEngine.test.mjs b/src/maps/globeEngine.test.mjs index 08b80d0bb..81ef36b50 100644 --- a/src/maps/globeEngine.test.mjs +++ b/src/maps/globeEngine.test.mjs @@ -173,6 +173,23 @@ test('a photoreal stack that fails to come back leaves the stack before it in pl googleTileset: loaded.tileset, onError: (message) => errors.push(message), }); + // The tile-failure listeners of the layers it adds, to fail their tiles. + const tileErrors = new Set(); + const add = renderer.globe.imagery.add; + renderer.globe.imagery.add = (...args) => { + const layer = add(...args); + const on = layer.on; + layer.on = (event, listener) => { + const off = on(event, listener); + if (event !== 'tileError') return off; + tileErrors.add(listener); + return () => { + tileErrors.delete(listener); + off(); + }; + }; + return layer; + }; await controller.setStack('esri-imagery', { silent: true }); assert.equal(renderer.globe.imagery.list().length, 1); renderer.globe.setPhotoreal = async (spec) => ({ @@ -190,5 +207,10 @@ test('a photoreal stack that fails to come back leaves the stack before it in pl assert.equal(renderer.globe.imagery.list().length, 1, 'its imagery stays'); assert.equal(engine.globeShown(host), true, 'on the shown globe'); assert.match(errors.at(-1), /refused/); + // Its tile failures still fall back, heard for the switch that kept it. + for (const listener of [...tileErrors]) listener({}); + for (const listener of [...tileErrors]) listener({}); + for (let i = 0; i < 20; i++) await new Promise((r) => setTimeout(r, 0)); + assert.equal(controller.getState().activeId, 'osm'); controller.destroy(); }); diff --git a/src/ui/cockpitEntryGate.test.mjs b/src/ui/cockpitEntryGate.test.mjs index cc1eca7bf..124fe36e7 100644 --- a/src/ui/cockpitEntryGate.test.mjs +++ b/src/ui/cockpitEntryGate.test.mjs @@ -14,6 +14,7 @@ import { bindFakeCesiumCamera, followEntity, } from '../testSupport/fakeCameraPort.mjs'; +import { followedOf } from '../data/followed.js'; import { fakeScenePorts } from '../testSupport/fakeCesiumScene.mjs'; import { createDependencies } from '../layers/awareness/dependencies.js'; import { CockpitCoordinator } from './cockpitCoordinator.js'; @@ -509,8 +510,10 @@ test('a ride handed to an aircraft on a layer Contacts turned on keeps that laye await settle(); assert.equal(cockpit.enter(), true); // NEXT hands the view to a military aircraft; Contacts turned its layer on. - // The follow's change adopts it as the ridden aircraft. + // The follow's change adopts it as the ridden aircraft: the Cockpit + // takes the camera from the follow. retrack({ layerId: 'military', info: MILITARY }); + assert.equal(followedOf(cockpit.viewer), null, 'adopted'); assert.equal(cockpit.readSubjectLayerId(), 'military'); await manager.setEnabled('ais-live-vessels', false, { origin: 'user' }); await settle();