Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 0cbb1cd42ec6eca95c567abc7785ab41277fc147
parent 47a1a3079ccdfddff9215c951f98f75caa34b8eb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed,  4 Nov 2026 20:24:57 -0500

umtool: Play's gate -- an item that has played is not waited for again in the same visit (a player mounted again under it when the deck composes: the clock runs on, as it always did; post-items, post-narration's fast-forward and thread-reads read it so); a post item fetched ahead waits for its card to be drawn and no more (looked at every frame), so a busy machine never runs the clock over an undrawn card (pp-6 86%, pp-8 83% at load 25)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/review/PlayCut.tsx | 21+++++++++++++++------
Mumtool/components/projects/review/PostItemPlayer.tsx | 36+++++++++++++++++++++---------------
Mumtool/docs/knobs.md | 4+++-
3 files changed, 39 insertions(+), 22 deletions(-)

diff --git a/umtool/components/projects/review/PlayCut.tsx b/umtool/components/projects/review/PlayCut.tsx @@ -409,12 +409,14 @@ export default function PlayCut({ ); // THE GATE (engine.ts): a post item plays once its player is ready -- its card drawn, its voice and its first // attachment able to play -- and the clock waits on it, never cutting it short (a buffer stall's wait). Fetched - // ahead (postPreload.ts), its player mounts "ahead" and plays on at once; the clock holds on the item before - // while it is still fetching. `postReady`: what the MOUNTED player said (one at a time; "gone" as it unmounts, - // so a player mounted again -- the deck composed -- is waited for afresh). + // ahead (postPreload.ts), its player is ready the frame its card is drawn; the clock holds on the item before + // while it is still fetching. `postReady`: what the MOUNTED player said (one at a time; "gone" as it unmounts). + // `started`: the item on screen once it has played -- a player mounted again under it (the deck composed) is not + // waited for (the clock runs on, as it always did). const entryOfRef = useRef(entryOf); entryOfRef.current = entryOf; const postReady = useRef<string | null>(null); + const started = useRef<string | null>(null); const gateAsked = useRef(new Map<string, number>()); const gate = useCallback<ItemGate>((id, next) => { const e = entryOfRef.current.get(id); @@ -425,10 +427,12 @@ export default function PlayCut({ if (since === undefined) gateAsked.current.set(key, (since = now)); if (now - since > GATE_MAX_MS) return "ready"; if (next) return postPreload.itemState(id) === "loading" ? "fetching" : "ready"; - // Its player mounted on bytes fetched ahead ("ahead": a srcdoc card, a blob voice due `lead` in), or says it is ready. - return postReady.current === id ? "ready" : "wait"; + if (started.current === id) return "ready"; + if (postReady.current !== id) return "wait"; + started.current = id; + return "ready"; }, []); - const onPostReady = useCallback((id: string, state: "ahead" | "ready" | "gone") => { + const onPostReady = useCallback((id: string, state: "ready" | "gone") => { if (state !== "gone") postReady.current = id; else if (postReady.current === id) postReady.current = null; }, []); @@ -875,6 +879,11 @@ export default function PlayCut({ // A new item on screen: its gate is asked afresh (a revisit waits as the first visit did). gateAsked.current.clear(); }, [ui.cur, plan]); + // Another item on screen: the one before is no longer "started" (a revisit waits as the first visit did). + const curId = plan.items[ui.cur]?.id ?? null; + useEffect(() => { + if (started.current !== curId) started.current = null; + }, [curId]); useEffect(() => { const items = plan.items; const i = ui.cur; diff --git a/umtool/components/projects/review/PostItemPlayer.tsx b/umtool/components/projects/review/PostItemPlayer.tsx @@ -499,12 +499,11 @@ export default function PostItemPlayer({ project, take = null, entry, plan, box, s, playing, cardKey = null, speed = 1, published = false, uncensored = false, scene = null, clock = null, joinFrom = null, onReady, }: { /** - * THIS player's readiness, for Play's clock (engine.ts `gate`): "ahead" as it mounts when its card, its voice - * and the attachment it opens on were all fetched ahead (postPreload.ts: it plays on at once); "ready" once its - * card is drawn and its voice and first attachment can play (or failed: nothing to wait for); "gone" as it - * unmounts (a player mounted again -- the deck composed -- is waited for afresh). + * THIS player's readiness, for Play's clock (engine.ts `gate`): "ready" once its card is drawn and its voice and + * first attachment can play (or failed: nothing to wait for) -- fetched ahead (postPreload.ts), as soon as its + * card is drawn, the rest being here; "gone" as it unmounts. */ - onReady?: (id: string, state: "ahead" | "ready" | "gone") => void; + onReady?: (id: string, state: "ready" | "gone") => void; project: string; take?: string | null; entry: Record<string, unknown> & { id: string }; @@ -853,21 +852,28 @@ export default function PostItemPlayer({ useEffect(() => { if (!onReadyRef.current) return; const mine = entry.id; - if (ahead) onReadyRef.current(mine, "ahead"); - const id = setInterval(() => { + // Looked at every frame: an item fetched ahead is ready the frame its card is drawn. + let raf = 0; + const look = () => { + raf = requestAnimationFrame(look); const node = wrap.current; const doc = readFrame.current?.contentDocument; if (!node || doc?.body?.getAttribute("data-post-ready") !== "1") return; - const a = voice.current; - // HAVE_FUTURE_DATA: it can play on from here; an error is nothing to wait for. - if (a && a.readyState < 3 && !a.error) return; - for (const v of Array.from(node.querySelectorAll<HTMLVideoElement>("video[data-post-video]"))) if (v.readyState < 2 && !v.error) return; - for (const im of Array.from(node.querySelectorAll<HTMLImageElement>("img[data-post-image]"))) if (!im.complete) return; - clearInterval(id); + // Fetched ahead, the rest is here (blobs); else the voice at HAVE_FUTURE_DATA and the first attachment's + // frame (an error is nothing to wait for). + if (!ahead) { + const a = voice.current; + if (a && a.readyState < 3 && !a.error) return; + for (const v of Array.from(node.querySelectorAll<HTMLVideoElement>("video[data-post-video]"))) if (v.readyState < 2 && !v.error) return; + for (const im of Array.from(node.querySelectorAll<HTMLImageElement>("img[data-post-image]"))) if (!im.complete) return; + } + cancelAnimationFrame(raf); + raf = 0; onReadyRef.current?.(mine, "ready"); - }, 40); + }; + raf = requestAnimationFrame(look); return () => { - clearInterval(id); + if (raf) cancelAnimationFrame(raf); onReadyRef.current?.(mine, "gone"); }; // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -606,7 +606,9 @@ in memory (a file over 64 MB, or past 384 MB in all, is left to its element) and player draws from them as it comes on screen, so the item is ready at its first frame; a seek or opening Play at a place fetches from there. An item not ready when its time comes HOLDS the clock, like a buffer stall: on the item before's last frame while it is still being fetched, then at its first second until its card is drawn and its voice -and first attachment can play (at most 15 s) — **loading…** over the picture — and then it plays in full. Every hold +and first attachment can play (fetched ahead: until its card is drawn, a frame or two; at most 15 s) — **loading…** +over the picture — and then it plays in full; once it has played, a player mounted again under it (the deck composed) +is not waited for. Every hold is counted (`window.__umtoolPlayEngine.stats.waits`) and logged in the console (`[play] held 412 ms on pp-3 …`). **The picture follows the clock**: by WebCodecs where the browser has it — each clip decoded from its window a few