Moving layers redraw as fast as they move on screen, 3 to 30 times a second

Satellites, flights and vessels held the render loop at the display's rate
while they were on, so a view of slow-moving marks drew 100-170 frames a
second. Each now reads how fast its fastest mark crosses the screen and asks
for a frame whenever that mark would move half a pixel: never fewer than 3 a
second (animated marks never stall), never more than 30 (room in the frame
for the rest of the scene). Below 12 a second the layer asks for one frame at
a time on a timer; from there it holds the loop at 15, 20 or 30, rates the
display divides evenly (renderPace.js).

The render governor takes a rate per hold: the highest asked wins, a hold
with no rate draws at the display's rate. Following a target is capped at
30. Steering the camera (a drag, a pinch, the wheel) still draws at the
display's rate; it ends when the last pointer lifts, the wheel rests, or the
page loses focus or is hidden.

Draw sets whose motion clock is the owner's ('frames: owner') ask for no
frames for moving rows or for rows written in place; the owner's pace does.
The vessels layer places its contacts at most 30 times a second and writes
every move of a pass to its icons in one batch.

Measured in Chrome on a still camera (draws a second, before -> after):
satellites over the whole globe 162 -> 6, at 1,500 km 114 -> 30; flights over
the whole globe 132 -> 10, Europe 53 -> 5, London 114 -> 9. Planes move at
most 0.6 px between draws.
This commit is contained in:
Sameh Khamis committed 2026-11-23 18:56:44 -08:00
1 parent 43bd25382d
commit d50f04efeb
30 files changed
+1262 -82

No files matched your search

+18 -14
View File
@@ -34,6 +34,7 @@ import { readLayerSource } from '../testSupport/readLayerSource.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { PACE_MIN_HZ } from '../renderPace.js';
import {
DETECTION_ENABLE_FADE_MS,
@@ -448,31 +449,34 @@ test('the render-governor gate covers the parked case, with teeth on the painter
// until some unrelated frame happens along.
//
// It cannot, and the reason is structural rather than lucky: an AIR bracket can
// only exist while an aircraft layer is enabled, and both aircraft layers take a
// continuous-render hold for their own per-frame fleet animation. So for exactly
// as long as there is anything to bracket, the scene is rendering every frame
// and the overlay repaints with it. (Measured live 2026-08-23 on a parked
// camera: an outside-aircraft population change moved the painted bracket count
// with no camera input, holds = ["flights"], requestRenderMode = false.)
// only exist while an aircraft layer is enabled, and both aircraft layers pace
// the render loop for their fleet (src/renderPace.js): never fewer than
// PACE_MIN_HZ frames a second however still the camera, more as the fleet
// moves faster on screen. So for exactly as long as there is anything to
// bracket, the scene keeps drawing and the overlay repaints with it, at most a
// third of a second behind. (Before the pace the layers held the loop on every
// frame; measured live 2026-08-23 on a parked camera, an outside-aircraft
// population change moved the painted bracket count with no camera input.)
//
// That is a COUPLING, so it deserves a pin. If a later perf pass strips these
// holds the way it stripped detection's — a reasonable-looking change — bracket
// That is a COUPLING, so it deserves a pin. If a later perf pass stops the
// aircraft layers pacing, or lets the pace's floor reach zero, bracket
// promptness goes with them, silently. This test is where that shows up.
test('aircraft brackets stay prompt because the aircraft layers hold the render loop', async () => {
test('aircraft brackets stay prompt because the aircraft layers pace the render loop', async () => {
assert.ok(PACE_MIN_HZ >= 3, 'a still scene still draws a few times a second');
for (const file of ['./flights.js', './militaryFlights.js']) {
const source = readLayerSource(new URL(file, import.meta.url));
const enable = /\n([ \t]*)enable\([\s\S]*?\n\1\},/.exec(source)?.[0];
assert.ok(enable, `${file}: enable() is still identifiable`);
assert.match(
enable,
/holdContinuousRender\('(flights|military)'\)/,
`${file}: enabling the layer must hold continuous render — detection no longer ` +
'holds one, so this is what keeps its AIR brackets repainting on a parked scene',
/parts\.rendering\._startPace\(\)/,
`${file}: enabling the layer must start its pace — detection no longer ` +
'holds the loop, so this is what keeps its AIR brackets repainting on a parked scene',
);
assert.match(
source,
/releaseContinuousRender\('(flights|military)'\)/,
`${file}: and the hold must be released, or the governor can never idle`,
/parts\.rendering\._stopPace\(\)/,
`${file}: and the pace must be stopped, or the governor can never idle`,
);
}
});