Retry a failed 3D model inside the engine instead of in the layers

A mover set whose glTF or atlas fails to load retries by itself after
retryAfterMs (1,500 ms by default), at most three attempts, on Cesium,
Navara and the fake engine alike: failed() is true while the latest
attempt failed and stays true after the last, ready() turns true when a
retry loads, and an instance given another pickId loads again. Healthy
models of the same class no longer load again when one fails.

The layers drop what they did instead: moverBank's rebuilds, the loops
that dropped failed handles in flights, military and local ADS-B, and the
tracked-model backoff in the aircraft display. The contract suite checks
the one behaviour on both engines, with a mutant that never retries.
This commit is contained in:
German Khokhlov committed 2026-11-10 16:04:01 +04:00
1 parent a90407d547
commit a07d9f5d85
22 files changed
+1039 -470

No files matched your search

+52 -8
View File
@@ -54,7 +54,7 @@ import { createGroundPicks, createGroundRegistry } from '../ground.js';
import { createMeshRegistry, meshRayDistance } from '../meshes.js';
import { createImageryRegistry } from '../imagery.js';
import { createLineRegistry } from '../lines.js';
import { createMoverRegistry } from '../movers.js';
import { createMoverRegistry, createMoverRetry } from '../movers.js';
import { createCpuPicker } from '../cpuPicks.js';
import { createFollowController } from '../follow.js';
import { normalizeSurfaceOptions } from '../surfaceDetail.js';
@@ -257,19 +257,63 @@ export function createFakeEngine(options = {}) {
};
});
// Movers keep their store for tests; commit counts as a render request.
const moverRegistry = createMoverRegistry((options) => {
const moverRegistry = createMoverRegistry((options, store) => {
const loads = new Map();
const ensure = (index) => {
const pickId = store.pickIds[index];
let entry = loads.get(index);
if (entry && entry.pickId === pickId) return entry;
entry?.retry.destroy();
entry = { pickId, ready: false, retry: null };
entry.retry = createMoverRetry(options.retryAfterMs, (attempt) => {
// A script can fail the first N attempts: (id, index, attempt) => attempt <= N.
if (scripted('moverFailed', [options.id, index, attempt], () => false))
entry.retry.fail();
else {
entry.ready = true;
entry.retry.succeed();
}
fake.renderRequests++;
});
loads.set(index, entry);
entry.retry.start();
return entry;
};
if (options.kind === 'sprite') ensure(undefined);
const current = (index) => {
const entry = loads.get(options.kind === 'sprite' ? undefined : index);
return options.kind === 'sprite' || entry?.pickId === store.pickIds[index]
? entry
: null;
};
const part = {
commits: 0,
commit() {
if (options.kind === 'model')
for (let index = 0; index < store.count; index++) ensure(index);
part.commits++;
fake.renderRequests++;
},
ready: (index) =>
!scripted('moverFailed', [options.id, index], () => false),
// Scripted as 'moverFailed' (set id, index) for a load that fails.
failed: (index) =>
scripted('moverFailed', [options.id, index], () => false),
destroy() {},
ready(index) {
if (options.kind === 'point') return true;
if (options.kind === 'sprite') return current(index).ready;
if (index !== undefined) return current(index)?.ready === true;
for (let at = 0; at < store.count; at++)
if (!current(at)?.ready) return false;
return true;
},
failed(index) {
if (options.kind === 'point') return false;
if (options.kind === 'sprite') return current(index).retry.failed();
if (index !== undefined) return current(index)?.retry.failed() === true;
for (let at = 0; at < store.count; at++)
if (current(at)?.retry.failed()) return true;
return false;
},
destroy() {
for (const entry of loads.values()) entry.retry.destroy();
loads.clear();
},
};
return part;
});