Report model load failures to model sets, and bound the tracked model's retries again

The renderer contract gains an optional event on model draw sets,
`on('loadFailed', (id, message) => ...)`, beside `ready`: a model's url
failed to load, once per failed load. The item stays in the set drawing
what it drew before; removing it and adding it again tries at once. A
renderer that cannot tell a failure may never fire it.

The Cesium draw port fires it once Cesium is done with the frame it
raised the error in, and not for a load that was superseded or whose item
went. The stub fails urls under `stub-fail:`, telling each load once. A
conformance check (`draw.models.loadFailed`) runs on both, with a model
url the dev server does not serve for Cesium.

The flights and military layers use it in place of rewriting every
unloaded model every 5 s. A fleet model whose load failed is removed and
added again 5 s later. The tracked model gets back its per-selection
budget: a failed load is let go and tried again 1.5 s later, and after
three failures the contact stays 2D until another is selected, as
before the models moved onto the draw port. A good load retires the
budget, and a model that loads after all is kept.
This commit is contained in:
Sameh Khamis committed 2026-11-07 19:44:15 -08:00
1 parent 396e7f0deb
commit 5370feb825
23 files changed
+536 -58

No files matched your search

+53
View File
@@ -4052,6 +4052,59 @@ test('a model load superseded or failed settles once', async () => {
}
});
test('a failed model load fires loadFailed once, after the frame, with why', async () => {
const { loads, restore } = fakeModelLoads();
try {
const scene = fakeScene();
const part = createCesiumDraw({
scene,
report: (error) => assert.fail(error),
});
const set = part.port.models({ id: 'm' });
const failed = [];
set.on('loadFailed', (id, message) => failed.push([id, message]));
const item = (id, url) => ({
id,
pos: { lon: 0, lat: 0 },
url,
orientation: { heading: 0, pitch: 0, roll: 0 },
});
// A load that rejects (the glTF did not fetch).
set.set([item('a', 'a.glb'), item('b', 'b.glb')]);
loads[0].reject(new Error('404 for a.glb'));
await settle();
assert.deepEqual(failed, [['a', '404 for a.glb']]);
// One that fails in its update: told after that update, not inside it.
loads[1].resolve();
await settle();
loads[1].model.errorEvent.raiseEvent(new Error('bad texture'));
assert.equal(failed.length, 1, 'not inside the model update');
await settle();
assert.deepEqual(failed[1], ['b', 'bad texture']);
// A listener may change the set: removing and adding again loads at once.
set.remove(['a']);
set.upsert([item('a', 'a.glb')]);
assert.equal(loads.length, 3, 'added again, loaded again');
// A load superseded before it fails is not told.
set.upsert([item('a', 'c.glb')]);
loads[2].reject(new Error('late'));
await settle();
assert.equal(failed.length, 2, 'a superseded load does not fire');
// Nor one whose item went before the failure was told.
loads[3].reject('plain reason');
set.remove(['a']);
await settle();
assert.equal(failed.length, 2, 'an item gone does not fire');
set.upsert([item('d', 'd.glb')]);
loads[4].reject({});
await settle();
assert.deepEqual(failed[2], ['d', 'the model did not load']);
set.dispose();
} finally {
restore();
}
});
test('a failed model load is tried again on a later update, after a wait', async () => {
const { loads, restore } = fakeModelLoads();
const realNow = Date.now;