A local video studio for your coding agent. Describe a video in one sentence: your agent directs, your machine renders. Claude Code, Codex, Cursor, Devin and more. No API keys, no uploads.
Python agent-skillsai-agentscaptionsclaude-codeclaude-code-pluginclaude-skillscodexcursorexplainer-videoffmpegheadless-chromekokoro-ttslocal-firstmanimmcp-servermotion-graphicstext-to-speechvideovideo-editingvideo-generation
showtime 0.4.6: check ends with an error naming the seek when a page stops answering on the timeline
Favio Vázquezdaf8ba2ba9e5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 13ac93c..e140f00 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -90,6 +90,12 @@ it.- **Fixed: the `25-nobel-physics-ice-telescope` example had text over text.** Its "2,450 m" depth mark sat under acaption line at 0:57; both depth marks now sit above their ruler ticks. The `tutorial` template's closing line,drawn over the dimmed app on purpose, is marked as layered, so a new tutorial project checks clean.+- **Fixed: `check` ends with an error when the page stops answering.** A seek on the dense timeline that missed its+ deadline only skipped that step, so a page whose renderer had stopped answering (while the browser itself still+ did) cost a minute per step, half an hour for a 3 s film, and check could wait with no end. Now a seek past its+ deadline asks the page for a quick answer: no answer, or a second late seek in a row, ends check with an error+ naming the seek and its last step, with a hint that points at the page's own code, and the browser closes with it.+ The dense timeline's other page reads, and the samples' text reads, wait under the same deadline.- **Fixed: `export html --interactive` packs a page's own fonts** (#71). The X-ray live page and the living diagram'sfigure packed the files of linked stylesheets only; a project's own `@font-face` in the page's `<style>`(`url("fonts/x.woff2")`) stayed a file the page's policy (`font-src data:`) blocks, so the text fell back to anotherdiff --git a/skills/showtime/scripts/check.mjs b/skills/showtime/scripts/check.mjsindex ebc27b7..a223795 100644--- a/skills/showtime/scripts/check.mjs+++ b/skills/showtime/scripts/check.mjs@@ -8,7 +8,7 @@ import crypto from 'node:crypto';import { fileURLToPath } from 'node:url';import { startServer } from './server.mjs';import { parseCli, runMain, failNow, stage, resolveProject, info, c, fmtTime, fmtDuration, parseTimes, parseTime, UserError, cpuCount, workName, briefOutput, runPyCli, hasPyModule, sinceLastLooked, printSince } from './lib/cli.mjs';-import { openBrowser, openPage, openLab, parseSize, paceSummary, watchBrowser, closeSoon, STUCK_HINT, onStuckShot, missing404 } from './lib/stagehost.mjs';+import { openBrowser, openPage, openLab, parseSize, paceSummary, watchBrowser, closeSoon, STUCK_HINT, onStuckShot, missing404, withPacedTimeout } from './lib/stagehost.mjs';import { textSnapshot, hideText, fontInfo, leafAlpha, captionCollisions, gpuProbeScript } from './lib/audit.mjs';import { phoneConfig, createPhone, readNeed, readingRate, ptOf, phoneLine } from './lib/phone.mjs';import { brandFindings } from './lib/brandcheck.mjs';@@ -325,9 +325,28 @@ async function main() {let pageFamilies = null; // @font-face families the page has loaded (lowercase), read oncelet seekMs = 0, shotMs = 0;const seekErrors = new Map();+ // A page that stops answering (its renderer stuck; the browser itself still answers watchBrowser's ping) ends+ // check naming the step. Before, a seek past its deadline only skipped the step, so a stuck page cost 60 s x pace+ // per step of the timeline (31 steps for a 3 s film), longer than any caller waits (macOS CI runners).+ let seekLate = 0; // seeks past their deadline in a row, on a page that still answers+ const PAGE_STUCK_HINT = 'the page\'s own code may be stuck there (its ST.onSeek handler or a script it runs at that time): open it with `showtime preview` and seek to that time; or the machine is too busy: close other heavy programs and retry';+ const pageStuck = async (what) => {+ const alive = await withPacedTimeout(sess.page.evaluate(() => 1), 15000, 'answering a ping', sess.pace).then(() => true, () => false);+ if (!alive) failNow(`the page stopped answering: ${what}; check's last step: ${doing}`, PAGE_STUCK_HINT);+ };+ /** A page call on the timeline under the seek's deadline: past it, a page that does not answer ends check. */+ const onPage = (p, what) => withPacedTimeout(p, 60000, what, sess.pace).catch(async (e) => {+ if (!e || !e.deadline) throw e;+ await pageStuck(String(e.message));+ return p; // slow, but the page answers: wait for it as before+ });const trySeek = async (x) => {- try { await sess.seek(x); return true; } catch (e) {+ try { await sess.seek(x); seekLate = 0; return true; } catch (e) {const msg = String(e.message || e).replace(/^page\.evaluate: (Error: )?/, '').split('\n')[0];+ if (e && e.deadline) {+ await pageStuck(msg);+ if (++seekLate >= 2) failNow(`the page's seeks stopped finishing: ${msg}, twice in a row; check's last step: ${doing}`, PAGE_STUCK_HINT);+ }const k = msg.split(' at t=')[0];if (!seekErrors.has(k)) seekErrors.set(k, { t: x, msg });return false;@@ -558,7 +577,7 @@ async function main() {let hasCaptions = null;const auditCaptionZone = async (st) => {if (hasCaptions === false || inTx(st)) return;- const cz = await sess.page.evaluate(captionCollisions, { width: W, height: H }).catch(() => null);+ const cz = await onPage(sess.page.evaluate(captionCollisions, { width: W, height: H }), 'reading the captions').catch(() => null);if (!cz) return;hasCaptions = cz.captions > 0;if (!cz.captioned || !cz.zone) return;@@ -581,7 +600,7 @@ async function main() {const shot = await sess.shot({ format: 'jpeg', quality: 90 });shotMs += Date.now() - t2; seekMs += t2 - t1;sheetItems.push({ buf: shot, label: `${fmtTime(st)}`, sub: `f${Math.round(st * fps)}` });- const snap = await sess.page.evaluate(textSnapshot, { width: W, height: H, full: true, labelGapEm: LABEL_GAP });+ const snap = await onPage(sess.page.evaluate(textSnapshot, { width: W, height: H, full: true, labelGapEm: LABEL_GAP }), 'reading the text');report.samples.push({ t: st, blocks: snap.blocks.length });for (const blk of snap.blocks) if (blk.opacity >= 0.5 && blk.onCanvas >= 0.5) seenText(blk.text, st, 'dom', blk.caption);if (isFilm) await auditFilmFrame(st, shot);@@ -788,7 +807,7 @@ async function main() {const raw = t0 + dir * k * stepW;const x = q(Math.max(0, Math.min(lastT, raw)));if (!(await trySeek(x))) break;- const pr = await sess.page.evaluate(leafAlpha, [...live]).catch(() => ({}));+ const pr = await onPage(sess.page.evaluate(leafAlpha, [...live]), 'reading the opacity').catch(() => ({}));for (const lid of [...live]) {const p = pr[lid];if (!p || !p.on || p.alpha < 0.05) { live.delete(lid); continue; } // the end of its visible window@@ -818,7 +837,7 @@ async function main() {}for (const [tm, lids] of [...plan].sort((x, y) => x[0] - y[0])) {if (!(await trySeek(tm))) continue;- const snap = await sess.page.evaluate(textSnapshot, { width: W, height: H, full: true, labelGapEm: LABEL_GAP });+ const snap = await onPage(sess.page.evaluate(textSnapshot, { width: W, height: H, full: true, labelGapEm: LABEL_GAP }), 'reading the text');await measureContrast(snap, tm, lids);}report.timings.settle = Date.now() - t;@@ -1067,14 +1086,14 @@ async function main() {if (!(await trySeek(gt))) continue;okGrid.push(gt);tiny.push(await sess.shot({ format: 'jpeg', quality: 70, scale: Math.min(1, 192 / W) }));- activeClips.push(await sess.page.evaluate(() => document.querySelectorAll('[data-start][data-active]').length));+ activeClips.push(await onPage(sess.page.evaluate(() => document.querySelectorAll('[data-start][data-active]').length), 'counting the active clips'));await auditCaptionZone(gt);let anyText = false;- const snap = await sess.page.evaluate(textSnapshot, { width: W, height: H, full: false, overlaps: true });+ const snap = await onPage(sess.page.evaluate(textSnapshot, { width: W, height: H, full: false, overlaps: true }), 'reading the text');const si = okGrid.length - 1;// canvas text on this step: the stage's records of every page canvas (raw fillText/strokeText), plus the film// API's F.text records below; all in frame pixels- const stepTexts = (await sess.page.evaluate(() => (window.__stCanvasText ? window.__stCanvasText() : [])).catch(() => []))+ const stepTexts = (await onPage(sess.page.evaluate(() => (window.__stCanvasText ? window.__stCanvasText() : [])), 'reading the canvas text').catch(() => [])).filter((t) => t.x < W && t.y < H && t.x + t.w > 0 && t.y + t.h > 0); // off the frame: not on screenconst bidText = new Map(snap.blocks.map((b) => [b.bid, b]));for (const [x, y, frac, px] of snap.overlaps || []) {@@ -1096,7 +1115,7 @@ async function main() {}const filmNow = new Set(); // the film API's texts on this step, measured belowif (isFilm) {- const fi = await filmInfo();+ const fi = await onPage(filmInfo(), 'reading the film');auditCovers(fi, gt);const kx = fi && fi.width ? W / fi.width : 1, ky = fi && fi.height ? H / fi.height : 1;{diff --git a/skills/showtime/tests/test_render.py b/skills/showtime/tests/test_render.pyindex 28b652b..a4c33a2 100644--- a/skills/showtime/tests/test_render.py+++ b/skills/showtime/tests/test_render.py@@ -42,7 +42,8 @@ RESULTS = {}def showtime(*args, check=True, timeout=300):- cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=ENV,+ # SHOWTIME_TIMEOUT under this call's own timeout: a stuck command ends itself naming its step instead of being killed+ cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=dict(ENV, SHOWTIME_TIMEOUT=str(max(30, timeout - 30))),stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",errors="replace", timeout=timeout)if check and cp.returncode != 0:@@ -1086,6 +1087,68 @@ Film.start({ look: 'dark', design: [960, 540], fonts: ['600 1em "Inter Variable"for word in ("Film readable", "decor tiny detail"):self.assertFalse([f for f in tiny if word in f["message"]], (word, tiny))+ def stuck_check(self, name, script):+ """check on a 3 s page with script in it, as a page that stops answering is checked: SHOWTIME_TEST_WAIT_SCALE+ 0.25 (the seek's 60 s deadline is 15 s, the probe's 15 s is 3.75 s) with the page open's own deadline kept at+ 300 s (SHOWTIME_TEST_OPEN_TIMEOUT 1200 x 0.25: a busy machine opens the page slowly, which is not under test;+ a Mac running hung browsers took over 30 s to open one, while 4 CPU burners alone did not slow it),+ SHOWTIME_TIMEOUT 200 (a check that does not give up says where it is), the browser's profile in its own+ temporary folder (its processes are found by it).+ -> (the completed check, seconds, the browser processes still running when it ended)"""+ proj = self.tmp / name+ write(proj / "showtime.json", json.dumps({"width": 640, "height": 360, "fps": 30, "duration": 3}))+ write(proj / "index.html", """<!doctype html><html><head><style>body{margin:0;background:#0b0d12;color:#fff}</style>+<script src="/_st/stage.js"></script></head><body><h1 id="h">Stuck page</h1>+<script>ST.onSeek(function (t) { document.getElementById('h').textContent = 'Stuck page ' + t.toFixed(2); });+%s</script></body></html>""" % script)+ tmp = Path(tempfile.mkdtemp(prefix="st-stuck-", dir=str(self.tmp)))+ env = dict(ENV, SHOWTIME_TEST_WAIT_SCALE="0.25", SHOWTIME_TEST_OPEN_TIMEOUT="1200", SHOWTIME_TIMEOUT="200",+ TMPDIR=str(tmp), TEMP=str(tmp), TMP=str(tmp))+ t0 = time.time()+ cp = subprocess.run([sys.executable, str(LAUNCHER), "check", str(proj), "--json", "--no-determinism", "--samples", "2"],+ env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", errors="replace",+ timeout=240)+ took = time.time() - t0++ def left(): # browser processes still running with their profile in tmp+ if os.name == "nt":+ cmd = ["powershell", "-NoProfile", "-Command", "Get-CimInstance Win32_Process | ForEach-Object { $_.CommandLine }"]+ else:+ cmd = ["ps", "-axww", "-o", "command="]+ out = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, encoding="utf-8", errors="replace",+ timeout=60).stdout+ return [x for x in out.splitlines() if str(tmp) in x and "--user-data-dir" in x]+ for _ in range(20):+ procs = left()+ if not procs:+ break+ time.sleep(1)+ return cp, took, procs++ def test_13h_check_ends_when_the_page_stops_answering(self):+ """A page that stops answering on the timeline ends check with an error naming where, instead of a check+ that skips step after step at the seek's deadline each (31 steps for 3 s; macOS CI runners), and leaves no+ browser behind: a seek that spins (between 1.25 s and 1.45 s, away from the samples: no answer to the probe),+ a seek that never finishes while the page still answers (two late seeks in a row), and a read on the+ timeline that spins (the step's canvas text)."""+ cases = (+ ("stuckseek", "ST.onSeek(function (t) { if (t >= 1.25 && t < 1.45) for (;;) {} });",+ ("the page stopped answering", "seek to 1.300s")),+ ("lateseek", "ST.onSeek(function (t) { if (t >= 1.25 && t < 1.45) return new Promise(function () {}); });",+ ("the page's seeks stopped finishing", "seek to 1.400s", "twice in a row")),+ ("stuckread", "window.__stCanvasText = function () { for (;;) {} };",+ ("the page stopped answering", "reading the canvas text")),+ )+ for name, script, says in cases:+ with self.subTest(name):+ cp, took, procs = self.stuck_check(name, script)+ self.assertEqual(cp.returncode, 1, cp.stderr[-2000:])+ for s in says:+ self.assertIn(s, cp.stderr, cp.stderr[-2000:])+ self.assertIn("showtime preview", cp.stderr, "the hint points at the page's own code")+ self.assertLess(took, 200, "check took %.0f s to give up on the stuck page" % took)+ self.assertEqual(procs, [], "the stuck page's browser was left running")+def test_14_check_judges_settled_frame_after_transition(self):"""Text sliding through the vertical safe zone during a push transition is a note naming thetransition; the settled frame after it is sampled and passes."""