fix(embed): an inline panel's timer frames move the camera, take input and run the clock again

When a host stops animation frames, the panel drew from a timer with the
viewer's render(): the camera's flight and input, the clock's tick, then a
draw if due. Through the frame port it called renderNow(), which on Cesium
only forced a draw, so flights stood still, drags and zooms did nothing
and the clock stopped. renderNow takes {ifDue: true}: one tick of the
loop as its own would run it, drawing only a frame that is due (the
widget's render() on Cesium; the stub's tick without a forced request).
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:43:13 -08:00
1 parent f4beb676ae
commit 03a7d8827a
9 files changed
+86 -22

No files matched your search

+4 -2
View File
@@ -25,7 +25,9 @@ function describeError(error) {
* Keep `renderer` drawing in an inline panel. Some hosts report a panel on
* screen as hidden, which stops the browser's animation frames and with them
* the renderer's own loop; while frames stop arriving, draw from a timer
* (`resize`, then `frame.renderNow()`). A frame that fails stops the timer,
* (`resize`, then a frame of the loop, `frame.renderNow({ifDue: true})`: the
* camera moves, input and the clock run, and it draws when due). A frame
* that fails stops the timer,
* its error reported in full. Returns a function that stops it.
* @param {import('../render/contract/renderer').Renderer} renderer
* @param {{windowRef?: Window, now?: () => number}} [options]
@@ -47,7 +49,7 @@ export function keepPanelRendering(
if (failed || now() - lastFrame < MISSED_FRAMES_MS) return;
try {
renderer.resize();
renderer.frame.renderNow();
renderer.frame.renderNow({ ifDue: true });
} catch (error) {
// Report the error in full: workers report plain objects, which
// would print as [object Object].
+7 -2
View File
@@ -19,7 +19,10 @@ test('a panel keeps drawing from a timer while animation frames stop', () => {
const drawn = [];
const renderer = {
resize: () => drawn.push('resize'),
frame: { renderNow: () => drawn.push('render') },
frame: {
renderNow: (options) =>
drawn.push(options?.ifDue ? 'loop frame' : 'forced frame'),
},
};
const stop = keepPanelRendering(renderer, {
windowRef: handles.windowRef,
@@ -33,7 +36,9 @@ test('a panel keeps drawing from a timer while animation frames stop', () => {
// Frames stop, as in a panel its host reports hidden: the timer draws.
clock = 400;
handles.tick();
assert.deepEqual(drawn, ['resize', 'render']);
// A frame of the loop, as the loop's own: the camera moves, input and
// the clock run, and it draws when due.
assert.deepEqual(drawn, ['resize', 'loop frame']);
stop();
assert.equal(handles.tick, null);
assert.equal(handles.frame, null);