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

+2 -19
View File
@@ -9,10 +9,7 @@
* less the members that would not be true of the application yet: the
* globe (it draws photoreal tiles the port does not know), `whenSettled`
* (it would not wait for them), `frame.setTime` (it would stop the
* application's clock), and the frame members that steer the loop
* (`holdContinuous`, `suspend`, `setTargetFps`) with the `diagnostics` that
* report them: `renderGovernor.js` and the page's visibility handling still
* own those settings, and two owners would undo each other. Those arrive with the layer families that need
* application's clock). Those arrive with the layer families that need
* them (phase 2 of the renderer plan); `checkRendererShape` lists what is
* still missing.
* Until a family is ported, its code reaches the Cesium viewer through
@@ -23,14 +20,6 @@ import { createApplicationViewer } from '../../app/viewer.js';
import { CONTRACT_VERSION } from '../contract/index.js';
import { cesiumCapabilities, createCesiumPorts } from './ports.js';
/** Frame members the application's own loop code still owns. */
const LOOP_OWNED = new Set([
'diagnostics',
'holdContinuous',
'setTargetFps',
'suspend',
]);
/**
* The members a transitional renderer has today.
* @typedef {Pick<import('../contract/renderer').Renderer,
@@ -109,13 +98,7 @@ export function createCesiumRendererPlugin({
contractVersion: CONTRACT_VERSION,
capabilities,
canvas: viewer.canvas,
frame: Object.freeze(
Object.fromEntries(
Object.entries(ports.frame).filter(
([name]) => !LOOP_OWNED.has(name),
),
),
),
frame: ports.frame,
draw: ports.draw,
camera: ports.camera,
query: ports.query,
-4
View File
@@ -342,11 +342,7 @@ const EXPECTED_MISSING = [
'draw.atlas',
'draw.clampState',
'draw.on',
'frame.diagnostics',
'frame.holdContinuous',
'frame.setTargetFps',
'frame.setTime',
'frame.suspend',
'renderer.credits',
'renderer.effects',
'renderer.globe',
+7 -2
View File
@@ -3,7 +3,8 @@
* @description The Cesium renderer's contract ports, built over a Cesium
* widget or viewer someone else made and configured: frame phases, the
* draw sets, `setView` and the pose, picks and projection, and capture.
* Building them changes nothing in the scene; only calls do.
* Building them puts the loop on demand (no holds yet, and no redraws for
* scene time alone); nothing else in the scene changes until a call.
*
* The conformance renderer (`sceneRenderer.js`) and the application's
* renderer (`appRenderer.js`) both use them, so what conformance
@@ -233,8 +234,12 @@ export function createCesiumPorts(widget, { capabilities }) {
if (scene.requestRenderMode === !continuous) return;
scene.requestRenderMode = !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 = 0;
let targetFps = widget.targetFrameRate > 0 ? widget.targetFrameRate : 0;
// Pending one-shot renders; disposal settles them rather than leave them
// attached to a scene that will not render again.
+12
View File
@@ -442,3 +442,15 @@ test('releasing the last hold asks for one more frame', () => {
assert.equal(requests(), before + 1, 'a second release does nothing');
ports.dispose();
});
test('the loop starts on demand and never draws for scene time alone', () => {
const { widget, scene } = tickingWidget();
scene.requestRenderMode = false;
scene.maximumRenderTimeChange = 0;
widget.targetFrameRate = 60;
const ports = createCesiumPorts(widget, { capabilities: all });
assert.equal(scene.requestRenderMode, true);
assert.equal(scene.maximumRenderTimeChange, Infinity);
assert.equal(ports.frame.diagnostics().targetFps, 60, 'the widget’s cap');
ports.dispose();
});