Idle frame rate in the app, timed line batching, KEY REQUIRED status

Three fixes to how the globe draws and reports loading.

**The idle frame rate is the app's rule.** The Cesium frame port capped the loop at `IDLE_FRAME_RATE` whenever nothing held it, so the rule lived inside the renderer. The render governor now sets the rate: the display's own while the loop is held, `IDLE_FRAME_RATE` while not. The frame port gains `onHeldChange(cb)`, which says when its first hold is taken and its last released (animated visual styles included), so the governor hears every hold. The quality setting's frame-rate cap is kept apart from the governor's rate, and the loop draws at the lower of the two, so neither overwrites the other.

**Line batching is timed.** A line set waited 30 drawn frames before its unchanged lines settled into a static batch (300 for the long wait), so the batch built twice as fast at 120 Hz as at 60 Hz, and took seconds at the idle rate. It now waits `SETTLE_MS` (500 ms) and `LONG_SETTLE_MS` (5 s), and moved shapes go back into their batches on the same timing.

**KEY REQUIRED.** A layer that cannot load without a provider key ended the global status chip LOAD FAILED. The chip now has a KEY REQUIRED outcome, ranked below a real failure: a layer whose stats say `keyRequired` ends KEY REQUIRED, any other failure still ends LOAD FAILED. Vessels report a missing AISStream key as `keyRequired` and name the key in the panel; a later outage clears it, as it is no longer the key that is missing.

Checked: the full suite (new tests for `onHeldChange`, the quality cap against the governor's rate, timed settling, and the chip with and without a key), format, boundaries, build, the stub renderer boot and the Cesium conformance run; in the browser, the idle and held frame rates; and the first-run check now asserts that with no keys set the chip never says LOAD FAILED.
This commit is contained in:
Sameh Khamis committed 2026-11-16 14:10:01 -08:00
1 parent 84d3e7b5ce
commit 0ed6cde956
33 files changed
+629 -179

No files matched your search

+4
View File
@@ -121,6 +121,10 @@ export function createIngestion({
ownsAisRequest(requestController, requestSessionId) &&
error?.name !== 'AbortError'
) {
// The key is missing only while the source says so; any other
// failure is an outage, not a key to add.
feed.transportStatus =
error?.code === 'key-required' ? 'missing-key' : null;
markUnavailable(error?.message || msg('AIS live load failed'));
console.warn('[Data:ais-live-vessels]', feed.error, error);
}
+38
View File
@@ -147,3 +147,41 @@ test('vessels are asked for by the area in view, and again only when the view mo
await ingestion.refreshIfMoved();
assert.deepEqual(asked.at(-1), { maxRows: 500 });
});
test('a source refusing for want of a key leaves the feed waiting for its key', async () => {
const keyless = Object.assign(new Error('AISSTREAM_API_KEY not set'), {
code: 'key-required',
});
const probe = setup({
getSnapshot: async () => {
throw keyless;
},
});
await probe.methods.update();
assert.equal(probe.feed.transportStatus, 'missing-key');
assert.equal(probe.feed.error, 'AISSTREAM_API_KEY not set');
const down = setup({
getSnapshot: async () => {
throw new Error('feed down');
},
});
await down.methods.update();
assert.notEqual(down.feed.transportStatus, 'missing-key');
});
test('a source failing for another reason after a missing key is an outage, not a key to add', async () => {
let fail = Object.assign(new Error('AISSTREAM_API_KEY not set'), {
code: 'key-required',
});
const probe = setup({
getSnapshot: async () => {
throw fail;
},
});
await probe.methods.update();
assert.equal(probe.feed.transportStatus, 'missing-key');
fail = new Error('feed down');
await probe.methods.update();
assert.equal(probe.feed.transportStatus, null);
assert.equal(probe.feed.error, 'feed down');
});
+18
View File
@@ -601,3 +601,21 @@ test('a virtual aid to navigation keeps its disc and its virtual flag', async ()
assert.equal(layer.testing._vesselRecordForTest('993672009').virtual, true);
assert.match(atob(icons.item('993672009').image.split(',')[1]), /<circle/);
});
test('a feed with no AISStream key reports its key as required, and a live one does not', async () => {
let current = snapshot([], {
transportStatus: 'missing-key',
complete: false,
});
const { layer } = setup({
async getSnapshot() {
return current;
},
});
assert.equal(layer.requiresKeyId, 'aisstream');
await layer.update();
assert.equal(layer.getStats().keyRequired, true);
current = snapshot([observation('111')]);
await layer.update();
assert.equal(layer.getStats().keyRequired, false);
});
+3
View File
@@ -299,6 +299,8 @@ export function createQueries({
icon: '◭',
source: 'AISStream',
// Without an AISStream key the feed cannot start; the panel names the key.
requiresKeyId: 'aisstream',
updateInterval: REFRESH_MS,
@@ -713,6 +715,7 @@ export function createQueries({
? 'unavailable'
: undefined,
transportStatus: state.feed.transportStatus,
keyRequired: state.feed.transportStatus === 'missing-key',
lastMessageAt: state.feed.lastMessageAt,
rawRowCount: state.feed.rawRowCount,
acceptedRowCount: state.feed.acceptedRowCount,