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

+54
View File
@@ -1754,6 +1754,60 @@ export function portChecks() {
},
{ capability: 'models' },
),
check(
'draw.models.loadFailed',
'a model set says when a model fails to load, and loads it when added again',
async (h, r) => {
if (!h.assets?.model || !h.assets?.missingModel)
return { skip: 'no missing model asset in this harness' };
const set = r.draw.models({ id: 'conf:models.loadFailed' });
const ready = [];
const failed = [];
set.on('ready', (id) => ready.push(id));
set.on('loadFailed', (id, message) => failed.push([id, message]));
const model = (id, url) => ({
id,
pos: { ...AUSTIN, height: 0 },
url,
orientation: { heading: 0, pitch: 0, roll: 0 },
});
const until = async (done) => {
for (let i = 0; i < 600 && !done(); i++) await drawn(h, r, 1);
};
set.set([
model('bad', h.assets.missingModel),
model('good', h.assets.model),
]);
await until(() => failed.length >= 1 && ready.length >= 1);
deepEqual(ready, ['good'], 'the good one is ready');
deepEqual(
failed.map(([id]) => id),
['bad'],
'the missing one failed',
);
ok(
typeof failed[0]?.[1] === 'string' && failed[0][1].length > 0,
'with a message',
);
equal(set.size(), 2, 'the failed item stays in the set');
// Removed and added again, it is tried at once, and fails again.
set.remove(['bad']);
set.upsert([model('bad', h.assets.missingModel)]);
await until(() => failed.length >= 2);
deepEqual(
failed.map(([id]) => id),
['bad', 'bad'],
'tried again when added again',
);
// Pointed at a url that loads, it is ready.
set.upsert([model('bad', h.assets.model)]);
await until(() => ready.length >= 2);
deepEqual(ready, ['good', 'bad'], 'a good url loads');
equal(failed.length, 2, 'no failure for a good url');
set.dispose();
},
{ capability: 'models' },
),
check(
'draw.models.update',
'a model moves, turns and restyles in place; only a new url loads it again',