mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
396e7f0deb
commit
5370feb825
23 files changed
+536
-58
No files matched your search
@@ -34,6 +34,12 @@ import {
|
||||
|
||||
const FRAME_MS = 1000 / 60;
|
||||
|
||||
/**
|
||||
* Model urls under this scheme fail to load (`loadFailed`), so tests can
|
||||
* see a failure; the stub loads nothing, and every other url is a model.
|
||||
*/
|
||||
export const STUB_FAILING_MODEL_SCHEME = 'stub-fail:';
|
||||
|
||||
/** Every setting the stub accepts, with its descriptor. */
|
||||
const KNOBS = Object.freeze([
|
||||
{ key: 'pixelRatio', kind: 'number', min: 0, max: 4, default: 0, cost: 1 },
|
||||
@@ -314,21 +320,37 @@ export function createStubRenderer(options = {}) {
|
||||
items: new Map(),
|
||||
show: spec.show ?? true,
|
||||
readyListeners: [],
|
||||
loadFailedListeners: [],
|
||||
};
|
||||
sets.set(spec.id, record);
|
||||
log('draw', kind, [spec]);
|
||||
// A model is ready once per load: when it is new or its url changes,
|
||||
// not when it is moved or restyled.
|
||||
// not when it is moved or restyled. One under the failing scheme fails
|
||||
// its load instead.
|
||||
// Each load is told once: a listener that starts another load of the
|
||||
// same item (or removes it) supersedes the one queued here.
|
||||
const loadTokens = new Map();
|
||||
const loads = (items) =>
|
||||
kind === 'models'
|
||||
? items
|
||||
.filter(
|
||||
(item) => record.items.get(String(item.id))?.url !== item.url,
|
||||
)
|
||||
.map((item) => String(item.id))
|
||||
.map((item) => {
|
||||
const token = {};
|
||||
loadTokens.set(String(item.id), token);
|
||||
return [String(item.id), token];
|
||||
})
|
||||
: [];
|
||||
const ready = (ids) => {
|
||||
for (const id of ids) deliver(record.readyListeners, id);
|
||||
const ready = (loading) => {
|
||||
for (const [id, token] of loading) {
|
||||
if (loadTokens.get(id) !== token || !record.items.has(id)) continue;
|
||||
loadTokens.delete(id);
|
||||
const url = String(record.items.get(id).url ?? '');
|
||||
if (url.startsWith(STUB_FAILING_MODEL_SCHEME))
|
||||
deliver(record.loadFailedListeners, id, `${url} does not load`);
|
||||
else deliver(record.readyListeners, id);
|
||||
}
|
||||
};
|
||||
const handle = {
|
||||
id: spec.id,
|
||||
@@ -369,9 +391,15 @@ export function createStubRenderer(options = {}) {
|
||||
requestRender('draw');
|
||||
},
|
||||
on(event, cb) {
|
||||
if (event !== 'ready') return () => {};
|
||||
const list =
|
||||
event === 'ready'
|
||||
? record.readyListeners
|
||||
: event === 'loadFailed'
|
||||
? record.loadFailedListeners
|
||||
: null;
|
||||
if (!list) return () => {};
|
||||
const entry = { cb, live: true };
|
||||
record.readyListeners.push(entry);
|
||||
list.push(entry);
|
||||
return () => {
|
||||
entry.live = false;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user