mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
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:
1 parent
84d3e7b5ce
commit
0ed6cde956
33 files changed
+629
-179
No files matched your search
+31
-23
@@ -116,22 +116,18 @@ const destroyedError = () => new Error('renderer destroyed');
|
||||
* @param {{capabilities: ReadonlySet<string>, credentials?: object,
|
||||
* cameraController?: import('../contract/camera').CameraControllerFactory,
|
||||
* now?: () => number,
|
||||
* date?: () => number,
|
||||
* idleFps?: number}} options
|
||||
* date?: () => number}} options
|
||||
* The renderer's capabilities, which gate the members that need them, and
|
||||
* the credentials its globe loads photoreal tiles and world data with
|
||||
* (`googleApiKey`, `googleTokens`, `worldDataToken`). `now` is the clock
|
||||
* each tick reads (`performance.now` by default; a test's virtual one);
|
||||
* `date`, the epoch ms a `live` motion clock reads (the system clock's by
|
||||
* default). With `idleFps`, the loop ticks at most that often while no
|
||||
* hold is out (Cesium ticks its clock and every update listener each
|
||||
* animation frame even when it draws nothing), and at the display's rate
|
||||
* while one is; `setTargetFps` then caps both, and the loop starts with no
|
||||
* cap of its own. Without it, the widget's own rate is the cap.
|
||||
* With
|
||||
* `cameraController`, the camera port is that controller's over Cesium's
|
||||
* camera (`controlledCamera.js`); the ports then have `attachInput` and
|
||||
* `suspendCamera`, which the renderer's input port is wired with.
|
||||
* default). The loop's rate starts as the widget's own; once set, it is
|
||||
* the lower of `setTargetFps`'s and the quality port's `targetFps` cap.
|
||||
* With `cameraController`, the camera port is that controller's over
|
||||
* Cesium's camera (`controlledCamera.js`); the ports then have
|
||||
* `attachInput` and `suspendCamera`, which the renderer's input port is
|
||||
* wired with.
|
||||
*/
|
||||
export function createCesiumPorts(
|
||||
widget,
|
||||
@@ -141,7 +137,6 @@ export function createCesiumPorts(
|
||||
cameraController,
|
||||
now: clockNow = () => performance.now(),
|
||||
date = null,
|
||||
idleFps = 0,
|
||||
},
|
||||
) {
|
||||
const scene = widget.scene;
|
||||
@@ -290,27 +285,30 @@ export function createCesiumPorts(
|
||||
|
||||
// Holds keep the loop drawing every frame; counted per reason.
|
||||
const holds = new Map();
|
||||
// Told when the first hold is taken and the last released.
|
||||
const heldListeners = listenerList(report);
|
||||
function applyHolds() {
|
||||
const continuous = holds.size > 0;
|
||||
if (idleFps > 0) applyRate();
|
||||
if (scene.requestRenderMode === !continuous) return;
|
||||
scene.requestRenderMode = !continuous;
|
||||
}
|
||||
/** The loop's rate: the cap, and at most `idleFps` while nothing holds. */
|
||||
function applyRate() {
|
||||
const idle = holds.size === 0 && idleFps > 0;
|
||||
const rate =
|
||||
idle && !(targetFps > 0 && targetFps < idleFps) ? idleFps : targetFps;
|
||||
widget.targetFrameRate = rate || undefined;
|
||||
heldListeners.fire(continuous);
|
||||
}
|
||||
// On demand means drawn when asked, held or the view changed: never
|
||||
// because scene time moved on by itself. With no holds yet, it starts so.
|
||||
scene.maximumRenderTimeChange = Infinity;
|
||||
scene.requestRenderMode = true;
|
||||
let suspended = false;
|
||||
let targetFps =
|
||||
idleFps <= 0 && widget.targetFrameRate > 0 ? widget.targetFrameRate : 0;
|
||||
if (idleFps > 0) applyRate();
|
||||
// The rate `setTargetFps` asks for (the application's), and the quality
|
||||
// port's cap; the loop draws at the lower of those set.
|
||||
let targetFps = widget.targetFrameRate > 0 ? widget.targetFrameRate : 0;
|
||||
let qualityFps = 0;
|
||||
function applyRate() {
|
||||
const rate =
|
||||
targetFps > 0 && qualityFps > 0
|
||||
? Math.min(targetFps, qualityFps)
|
||||
: targetFps || qualityFps;
|
||||
widget.targetFrameRate = rate || undefined;
|
||||
}
|
||||
|
||||
// Pending one-shot renders; disposal rejects them rather than leave them
|
||||
// attached to a scene that will not render again.
|
||||
@@ -369,6 +367,7 @@ export function createCesiumPorts(
|
||||
if (holds.size === 0) scene.requestRender();
|
||||
};
|
||||
},
|
||||
onHeldChange: (cb) => heldListeners.on(cb),
|
||||
/** Cesium can idle, so it draws on demand. */
|
||||
mode: () => 'demand',
|
||||
diagnostics: () => ({
|
||||
@@ -429,6 +428,7 @@ export function createCesiumPorts(
|
||||
capabilities,
|
||||
requestRender: (reason) => frame.requestRender(reason),
|
||||
date,
|
||||
now: clockNow,
|
||||
});
|
||||
const { port: draw, sets, tilesets } = drawPart;
|
||||
|
||||
@@ -494,6 +494,13 @@ export function createCesiumPorts(
|
||||
report,
|
||||
tickStarted: () => tickNow,
|
||||
gl: capabilities.has('gpuTiming') ? webglContext(scene) : null,
|
||||
fpsCap: {
|
||||
get: () => qualityFps,
|
||||
set(fps) {
|
||||
qualityFps = fps > 0 ? fps : 0;
|
||||
applyRate();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const creditsPart = createCesiumCredits({
|
||||
@@ -837,6 +844,7 @@ export function createCesiumPorts(
|
||||
// A listener that disposes the renderer stops the rest of its event.
|
||||
for (const list of Object.values(rendererListeners)) list.clear();
|
||||
for (const list of Object.values(frameListeners)) list.clear();
|
||||
heldListeners.clear();
|
||||
drawPart.dispose();
|
||||
cameraPart.dispose();
|
||||
creditsPart.dispose();
|
||||
|
||||
Reference in new issue
Block a user