fix(globe): Navara redraws after a map change while its tiles arrive

Phase-4 QA: after a map-stack switch at the whole-globe view Navara
sometimes showed the new map only seconds later. Navara 0.2.1 reports idle
and stops drawing before a raster tile it fetched arrives, so the last
frame stays stale until something else asks for one. Every engine.maps
change (base imagery, terrain, photoreal tiles, their release) now asks for
a frame and keeps asking every 250 ms for 6 s, then the engine idles again.

scripts/qa-map-switch.mjs switches the stack (photoreal / Esri / OSM) at
18 000 km on each engine, waits for the tiles, hashes the picture, forces
frames and hashes again: a change means a stale picture. Before: Navara 3/8
switches drew the new picture by themselves; after: Navara 8/8, Cesium 8/8.
This commit is contained in:
German Khokhlov committed 2026-10-16 23:00:15 +04:00
1 parent ba039f7974
commit 907cb2092d
3 files changed
+87 -8

No files matched your search

+45
View File
@@ -295,3 +295,48 @@ test('releasePhotorealTiles forgets the source and takes its tiles away if shown
assert.equal(maps.current().photoreal, null);
assert.equal(layersOf(view, '3d-tiles').length, 0);
});
test('after a map change Navara keeps redrawing while tiles arrive, then stops', async () => {
const view = fakeView();
const timers = [];
let now = 0;
const { maps, destroy } = createNavaraMaps(view, {
setInterval: (fn, ms) => {
const timer = { fn, ms, cleared: false };
timers.push(timer);
return timer;
},
clearInterval: (timer) => {
if (timer) timer.cleared = true;
},
now: () => now,
});
const tick = (ms) => {
for (let t = 0; t < ms; t += 250) {
now += 250;
for (const timer of timers) if (!timer.cleared) timer.fn();
}
};
await maps.setBaseImagery({ kind: 'osm' });
const afterChange = view.frames;
tick(1000);
// Navara 0.2.1 can report idle and stop drawing before a raster tile it
// fetched arrives: the engine asks for frames for a while after a change.
assert.ok(view.frames >= afterChange + 4, `frames ${view.frames}`);
tick(10_000);
const settled = view.frames;
tick(5_000);
assert.equal(view.frames, settled, 'idle again once the window ends');
assert.ok(
timers.every((timer) => timer.cleared),
'no timer left running',
);
// Another change opens a new window; destroy ends it.
await maps.setBaseImagery({ kind: 'esri-imagery' });
tick(500);
assert.ok(view.frames > settled + 1);
destroy();
const atDestroy = view.frames;
tick(2000);
assert.equal(view.frames, atDestroy);
});