Skip to content

Commit 525d817

Browse files
committed
perf(core): a scene another scene reads runs at boot, before its readers
1 parent f9245bf commit 525d817

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎packages/core/src/compiler/inlineSubCompositions.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
} from "./compositionAssembly";
4848
import {
4949
REACHED_BY_ROOT_REASON,
50+
READ_BY_SCENE_REASON,
5051
SCENE_EAGER_ATTR,
5152
SCENE_NO_SWAP_ATTR,
5253
SCENE_PART_ATTR,
@@ -845,7 +846,7 @@ export function keepScenesReadAtBootEager(
845846
for (const provider of readsOf(reader)) {
846847
const host = sceneHosts.get(provider);
847848
if (!host || host.hasAttribute(SCENE_EAGER_ATTR)) continue;
848-
host.setAttribute(SCENE_EAGER_ATTR, `${reader} reads it`);
849+
host.setAttribute(SCENE_EAGER_ATTR, `${reader} ${READ_BY_SCENE_REASON}`);
849850
eager.push(provider);
850851
}
851852
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { REACHED_BY_ROOT_REASON, SCENE_EAGER_ATTR, SCENE_PART_ATTR } from "../sceneParts";
1+
import {
2+
READ_BY_SCENE_REASON,
3+
REACHED_BY_ROOT_REASON,
4+
SCENE_EAGER_ATTR,
5+
SCENE_PART_ATTR,
6+
} from "../sceneParts";
27
import { fontFamilyKey } from "./afterFonts";
38
import { parseStrictFiniteTimingNumber } from "./playbackRate";
49
import { skipsHiddenImages } from "./timedClipHide";
@@ -26,7 +31,7 @@ function holdable(host: Element | undefined): HeldScene | null {
2631
if (start == null || duration == null || start <= SCENE_LEAD_SECONDS) return null;
2732
const eager = host.getAttribute(SCENE_EAGER_ATTR);
2833
if (eager == null) return { host, start, end: start + duration, scripts: [] };
29-
if (eager.startsWith(REACHED_BY_ROOT_REASON)) return null;
34+
if (eager.startsWith(REACHED_BY_ROOT_REASON) || eager.endsWith(READ_BY_SCENE_REASON)) return null;
3035
return { host, start: -Infinity, end: Infinity, scripts: [] };
3136
}
3237

‎packages/core/src/sceneParts.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const SCENE_EAGER_ATTR = "data-hf-scene-eager";
99

1010
export const REACHED_BY_ROOT_REASON = "a script outside the scene selects";
1111

12+
export const READ_BY_SCENE_REASON = "reads it";
13+
1214
/** Hashes of one preview document: everything outside the scene parts, and each scene's parts. */
1315
export interface SceneParts {
1416
shared: string;

0 commit comments

Comments
 (0)