mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
Stop scene attachments of Bhote Koshi, GhostMaps, cables and infrastructure waiting once their scene is released
This commit is contained in:
1 parent
cf6d04b7db
commit
9cc34e324f
7 files changed
+209
-14
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { waitForSignal } from '../../sources/requestDeadline.js';
|
||||
/** The dataset is acquired once per activation, independently of scene attachment. */
|
||||
export function createCableSessionLayer({
|
||||
source,
|
||||
@@ -75,7 +76,7 @@ export function createCableSessionLayer({
|
||||
init(viewer, ctx) {
|
||||
return this.attachRenderer(viewer, ctx);
|
||||
},
|
||||
attachRenderer(viewer, { engine } = {}) {
|
||||
attachRenderer(viewer, { engine, signal = null } = {}) {
|
||||
if (viewer) {
|
||||
const legacy = createCesium({ label: source.label, fetch: read });
|
||||
legacy.init(viewer);
|
||||
@@ -95,7 +96,13 @@ export function createCableSessionLayer({
|
||||
stats: () => legacy.getStats(),
|
||||
};
|
||||
} else display = createNavara(engine);
|
||||
if (enabled) return show();
|
||||
// The cable data load belongs to the session and keeps running; only
|
||||
// this scene's wait for it ends when the scene is released. show()
|
||||
// draws nothing into a display that was released meanwhile.
|
||||
if (enabled)
|
||||
return waitForSignal(show(), signal).catch((error) => {
|
||||
if (!signal?.aborted) throw error;
|
||||
});
|
||||
},
|
||||
detachRenderer() {
|
||||
const owner = display;
|
||||
|
||||
@@ -33,3 +33,40 @@ test('cables arriving during handoff belong to the incoming display', async () =
|
||||
assert.equal(reads, 1);
|
||||
layer.destroy();
|
||||
});
|
||||
|
||||
test('a released scene stops waiting for a stalled cable load, which stays in the session', async () => {
|
||||
let resolve;
|
||||
const shown = [];
|
||||
const layer = createCableSessionLayer({
|
||||
source: {
|
||||
label: 'fixture',
|
||||
fetch: () =>
|
||||
new Promise((done) => {
|
||||
resolve = done;
|
||||
}),
|
||||
},
|
||||
createNavara: (engine) => ({
|
||||
show: (dataset) => shown.push([engine, dataset]),
|
||||
destroy() {},
|
||||
hide() {},
|
||||
}),
|
||||
});
|
||||
layer.init(null, { engine: 'outgoing' });
|
||||
const pending = layer.enable();
|
||||
layer.detachRenderer();
|
||||
const scene = new AbortController();
|
||||
const attaching = layer.attachRenderer(null, {
|
||||
engine: 'released',
|
||||
signal: scene.signal,
|
||||
});
|
||||
scene.abort();
|
||||
await attaching;
|
||||
layer.detachRenderer();
|
||||
const dataset = { cables: { features: [] }, landingPoints: { features: [] } };
|
||||
resolve(dataset);
|
||||
await pending;
|
||||
assert.deepEqual(shown, []);
|
||||
await layer.attachRenderer(null, { engine: 'next' });
|
||||
assert.deepEqual(shown, [['next', dataset]]);
|
||||
layer.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user