Scope render demand to each scene attachment

Give each scene its own render governor, owner holds and recent idle requests.
Make the Cesium render backend own its request mode directly, so the governor
drives engine.render on both engines without a dependency back from Cesium.
Route layer requests through their attached engine and capture the attachment's
governor for camera motions, orbit, annotations and shell controls. Release
retained-layer holds before clearing the outgoing engine, and destroy the
governor after scene consumers have detached.

Preserve Cesium's owner-keyed holds, pre-install buffering, last-release settling
frame and one-shot requests during continuous rendering. Navara keeps the same
render policy. There is no intended visible change on either engine. Simultaneous
scenes no longer share holds, and an old captured service cannot release a
replacement attachment's hold. Cover both rules on fake and headless Cesium
engines, including an old orbit ending after reattachment.

Viewer-reference lines fall from 910 to 891, Navara-kind checks from 2 to 1,
and engine-name lines from 33 to 32. All other coupling counts stay unchanged.

Checked in the browser, keyless: qa-perf passes on both engines with the
same idle, active and release counts as before (24 checks on Cesium, 22 on
Navara).
This commit is contained in:
German Khokhlov committed 2026-11-07 16:56:34 +04:00
1 parent 4252ed0798
commit 0459ee6d58
87 files changed
+720 -935

No files matched your search

+23 -13
View File
@@ -32,9 +32,8 @@ import aisLiveVesselsLayer, {
} from './aisLiveVessels.js';
import militaryInstallationsLayer from './militaryInstallations.js';
import {
_resetRenderGovernorForTest,
getRenderGovernorDiagnostics,
installRenderGovernor,
renderGovernorFor,
} from '../renderGovernor.js';
import {
AWARENESS_RADIUS_M,
@@ -54,7 +53,10 @@ import { registerLayerRenderers } from '../app/layers/renderers.js';
// the layer through the renderer registry, under an engine kind of its own.
const VIEWER_ENGINE = 'awareness-viewer-test';
registerLayerRenderers(VIEWER_ENGINE, {
'military-awareness': ({ viewer }) => ({
'military-awareness': (engine) => {
const { viewer } = engine;
return {
engine,
container: viewer.container,
canvas: viewer.canvas,
get camera() {
@@ -70,9 +72,21 @@ registerLayerRenderers(VIEWER_ENGINE, {
viewer.camera.flyToBoundingSphere({ center, radius }, { duration }),
createRim: () => ({ move() {}, setAlpha() {}, destroy() {} }),
createPulses: () => null,
}),
};
},
});
const viewerEngine = (viewer) => ({ kind: VIEWER_ENGINE, viewer });
const viewerEngines = new WeakMap();
const viewerEngine = (viewer) => {
if (!viewerEngines.has(viewer)) viewerEngines.set(viewer, {
kind: VIEWER_ENGINE, viewer,
render: {
request: () => viewer.scene.requestRender?.(),
setContinuous: (enabled) => { viewer.scene.requestRenderMode = !enabled; },
isContinuous: () => viewer.scene.requestRenderMode === false,
},
});
return viewerEngines.get(viewer);
};
const militaryAwarenessSource = readLayerSource(
new URL('./militaryAwareness.js', import.meta.url),
@@ -3922,13 +3936,12 @@ test('parked Contacts takes no continuous-render hold and requests at most the p
{ icao24: 'neighbour-flight', position: neighbour, distanceM: 4000 },
],
});
_resetRenderGovernorForTest();
const runtime = installAwarenessRuntime();
const holds = () => getRenderGovernorDiagnostics().holds;
const holds = () => getRenderGovernorDiagnostics(viewerEngine(runtime.viewer)).holds;
try {
Date.now = () => clockMs;
installRenderGovernor(runtime.viewer);
renderGovernorFor(viewerEngine(runtime.viewer)).install();
runtime.viewer.camera = {
positionWC: new Cesium.Cartesian3(1_000_000, 200_000, 300_000),
heading: 0,
@@ -4003,7 +4016,6 @@ test('parked Contacts takes no continuous-render hold and requests at most the p
Date.now = realNow;
runtime.restore();
restoreCollections();
_resetRenderGovernorForTest();
}
});
@@ -4058,13 +4070,12 @@ test('a moving view over failed feeds takes no continuous-render hold', () => {
// Every dependency reports unavailable, so every cohort summarizes to count
// null — the exact state the old Boolean(state.results) gate still held for.
const restoreCollections = stubAwarenessCollections({});
_resetRenderGovernorForTest();
const runtime = installAwarenessRuntime({ isEnabled: () => false });
const holds = () => getRenderGovernorDiagnostics().holds;
const holds = () => getRenderGovernorDiagnostics(viewerEngine(runtime.viewer)).holds;
try {
Date.now = () => clockMs;
installRenderGovernor(runtime.viewer);
renderGovernorFor(viewerEngine(runtime.viewer)).install();
runtime.viewer.camera = {
positionWC: new Cesium.Cartesian3(1_000_000, 200_000, 300_000),
heading: 0,
@@ -4096,7 +4107,6 @@ test('a moving view over failed feeds takes no continuous-render hold', () => {
Date.now = realNow;
runtime.restore();
restoreCollections();
_resetRenderGovernorForTest();
}
});