Keep the render governor's holds on the frame port

The governor no longer writes the Cesium scene's render mode itself: each
owner holds the renderer's frame port once, requests go to it, and the
port is the one place the loop's mode is set. The port now also keeps
the loop from redrawing for scene time alone, which the governor did.

The application installs the governor as soon as its renderer exists and
holds the loop continuous ('boot') until its tools are up, where the
governor used to be installed, so boot draws as before. The hidden-tab
suspension goes through the port too, and the application's renderer now
has the whole frame port.
This commit is contained in:
Sameh Khamis committed 2026-11-05 17:24:34 -08:00
1 parent e6d22e55d7
commit d969df3d37
16 files changed
+192 -113

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
/**
* 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`. 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 apply = () => {
scene.requestRenderMode = holds.size === 0;
};
apply();
return {
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?.();
};
},
};
}