mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
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.
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
/**
|
|
* A frame port over a fake Cesium scene, for tests of code that steers the
|
|
* render loop through `renderGovernor.js`. It writes the scene the way the
|
|
* Cesium port does (`src/render/cesium/ports.js`): holds, counted per
|
|
* reason, keep `requestRenderMode` false; releasing the last asks for one
|
|
* frame; a request is the scene's `requestRender`; the first hold and the
|
|
* last release are told to `onHeldChange`; a rate set is kept as the
|
|
* scene's `targetFps`. Only the members the governor uses. One port per
|
|
* scene, so a test can uninstall what it installed.
|
|
* @param {{requestRenderMode?: boolean, requestRender?: () => void}} scene
|
|
*/
|
|
export function framePortFor(scene) {
|
|
let port = ports.get(scene);
|
|
if (!port) ports.set(scene, (port = makePort(scene)));
|
|
return port;
|
|
}
|
|
|
|
const ports = new WeakMap();
|
|
|
|
function makePort(scene) {
|
|
const holds = new Map();
|
|
const heldListeners = new Set();
|
|
let wasHeld = false;
|
|
const apply = () => {
|
|
const held = holds.size > 0;
|
|
scene.requestRenderMode = !held;
|
|
if (held === wasHeld) return;
|
|
wasHeld = held;
|
|
for (const cb of [...heldListeners]) cb(held);
|
|
};
|
|
apply();
|
|
return {
|
|
onHeldChange(cb) {
|
|
heldListeners.add(cb);
|
|
return () => heldListeners.delete(cb);
|
|
},
|
|
diagnostics: () => ({ holds: [...holds.keys()] }),
|
|
setTargetFps(fps) {
|
|
scene.targetFps = fps;
|
|
},
|
|
requestRender() {
|
|
scene.requestRender?.();
|
|
},
|
|
holdContinuous(reason) {
|
|
holds.set(reason, (holds.get(reason) ?? 0) + 1);
|
|
apply();
|
|
let released = false;
|
|
return () => {
|
|
if (released) return;
|
|
released = true;
|
|
const left = holds.get(reason) - 1;
|
|
if (left > 0) holds.set(reason, left);
|
|
else holds.delete(reason);
|
|
apply();
|
|
if (holds.size === 0) scene.requestRender?.();
|
|
};
|
|
},
|
|
};
|
|
}
|