Launches and satellites leave the world clock when destroyed

Both layers registered their time coverage with the page's world clock when
created and never unregistered it, so an application destroyed and started
again kept each old layer, and its scene and tiles, reachable through the clock.
They now unregister on destroy and register again on init, as earthquakes do.
This commit is contained in:
Sameh Khamis committed 2026-11-16 21:18:58 -08:00
1 parent 9239d3efff
commit ee306a46fc
3 files changed
+42 -4

No files matched your search

+26
View File
@@ -5,6 +5,7 @@ import http from 'node:http';
import { EventEmitter, once } from 'node:events';
import test from 'node:test';
import * as Cesium from 'cesium';
import { worldClock } from '../../time/worldClock.js';
import { createSatelliteSource } from './source.js';
import { createState } from './state.js';
import { createControls } from './controls.js';
@@ -309,3 +310,28 @@ test('destroy aborts an in-flight response and initialization starts with new ow
assert.equal(f.stats().count, CORE.length);
assert.equal(f.feed(), 'nominal');
});
test('destroy takes the layer off the world clock, and init puts it back', async (t) => {
// Each registration the layer makes, while it stands.
const register = worldClock.register;
const standing = new Set();
worldClock.register = (source) => {
standing.add(source);
const off = register.call(worldClock, source);
return () => {
standing.delete(source);
off();
};
};
t.after(() => {
worldClock.register = register;
});
const f = await fixture(t);
const mine = () =>
[...standing].filter(({ id }) => id === 'satellites').length;
assert.equal(mine(), 1);
f.parts.lifecycle.methods.destroy(f.viewer);
assert.equal(mine(), 0);
await f.parts.lifecycle.methods.init(f.viewer);
assert.equal(mine(), 1);
});