Skip to content

Commit 5a54583

Browse files
committed
fix(core): a seek into a scene still mounting as a neighbour waits for that mount
1 parent 25f5ae3 commit 5a54583

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎packages/core/src/runtime/init.swapScenes.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,6 +1836,19 @@ describe("the preview's scene window", () => {
18361836
expect(parked()).toEqual(["s2"]);
18371837
});
18381838

1839+
it("waits for the scene a seek lands in while its mount as a neighbour is still running", async () => {
1840+
bootWindowed([S0, S1, S2], trackingRoot().root);
1841+
await tick();
1842+
await seekAndSettle(5);
1843+
for (let i = 0; i < 5; i++) await tick();
1844+
expect(parked()).toEqual(["s0", "s1"]);
1845+
// Once s0 is in, s1 mounts as its neighbour; this seek lands in s1 meanwhile.
1846+
await seekAndSettle(0.5);
1847+
window.__player?.seek(2.5);
1848+
await window.__hfWaitForSeekCompletion?.();
1849+
expect(sceneHost("s1").textContent).toBe("one");
1850+
});
1851+
18391852
it("keeps drawing the scene it showed while the scene a seek lands in mounts", async () => {
18401853
bootWindowed([S0, S1, S2], trackingRoot().root);
18411854
await tick();

‎packages/core/src/runtime/init.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4439,7 +4439,10 @@ export function initSandboxRuntimeModular(): void {
44394439
const landed = windowScenes.find(
44404440
({ name, start, end }) => start <= time && time <= end && parked(name),
44414441
);
4442-
if (windowWork) return landed !== undefined;
4442+
if (windowWork) {
4443+
if (landed) registerSeekCompletion(windowWork.then(() => windowWork));
4444+
return landed !== undefined;
4445+
}
44434446
const near = scenesWanted(windowScenes, time, clock.isPlaying());
44444447
for (const name of heldScenes) near.add(name);
44454448
const key = [...near].join("\n");

0 commit comments

Comments
 (0)