Skip to content

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.

showtime 0.4.1 (draft): deterministic pace tests, late worker browsers closed, timeout diagnostics

Favio Vázquez823a76d58947
diff --git a/skills/showtime/scripts/render.mjs b/skills/showtime/scripts/render.mjs
index 8b50649..0514a72 100644
--- a/skills/showtime/scripts/render.mjs
+++ b/skills/showtime/scripts/render.mjs
@@ -736,7 +736,16 @@ async function main() {
// every browser was started before the capture (whole videos); a worker opens its page, then takes runs
// until none is left
const started = new Array(workers).fill(false);
- const jobs = Array.from({ length: workers }, async (_, w) => {
+ const jobs = Array.from({ length: workers }, (_, w) => workerJob(w).finally(() => {
+ // a worker that took no frames is not waited for (below): the browser it launched or the page it opened
+ // after the capture ended (and after render closed its browsers) is closed here, or it keeps the command
+ // from exiting (a span's second browser started late on a busy machine)
+ if (w > 0 && !started[w]) {
+ if (wsess[w]) closeSoon(wsess[w].close(), 5000);
+ if (browsers[w]) closeSoon(browsers[w].browser.close());
+ }
+ }));
+ async function workerJob(w) {
if (w > 0 && !browsers[w]) {
const pre = early[w - 1];
browsers[w] = pre ? await pre.catch(() => openBrowser({ gpu, ownSignals: true, args: renderFlags() })) : await openBrowser({ gpu, ownSignals: true, args: renderFlags() });
@@ -759,7 +768,7 @@ async function main() {
started[w] = true;
await captureRun(w, run);
}
- });
+ }
// a worker still opening its page when the others have taken and drawn every frame is not waited for
await new Promise((resolve, reject) => {
const done = new Array(workers).fill(false);
diff --git a/skills/showtime/tests/test_motion.py b/skills/showtime/tests/test_motion.py
index daa151e..b41ccdd 100644
--- a/skills/showtime/tests/test_motion.py
+++ b/skills/showtime/tests/test_motion.py
@@ -41,13 +41,32 @@ from st.launcher import build_env, showtime_home # noqa: E402
FAST = "--fast" in sys.argv
ENV = build_env(showtime_home())
+# a browser that stops answering (seen on macOS CI runners) ends the command with the step it was stuck at well
+# inside the test's 600 s: the page-open deadline (5 min x the page's pace, twice) and the screenshot wait (10 min)
+# are longer than the test's own limit
+ENV["SHOWTIME_TEST_OPEN_TIMEOUT"] = "90"
+ENV["SHOWTIME_SHOT_TIMEOUT"] = "120"
RESULTS = {}
+def _log_tails(args, since):
+ """The render.log / check logs a command wrote (under the paths it was given), newest first, for a timeout."""
+ roots = [Path(str(a)) for a in args if Path(str(a)).is_dir()]
+ logs = sorted({f for r in roots for f in r.rglob("logs/*.log") if f.stat().st_mtime >= since},
+ key=lambda f: f.stat().st_mtime, reverse=True)
+ return "\n".join("--- %s\n%s" % (f, f.read_text(encoding="utf-8", errors="replace")[-2500:]) for f in logs[:3]) or "(no log)"
+
+
def showtime(*args, check=True, timeout=600):
- cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=ENV,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
- errors="replace", timeout=timeout)
+ t0 = time.time()
+ try:
+ cp = subprocess.run([sys.executable, str(LAUNCHER)] + [str(a) for a in args], env=ENV,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
+ errors="replace", timeout=timeout)
+ except subprocess.TimeoutExpired as e:
+ err = e.stderr.decode("utf-8", "replace") if isinstance(e.stderr, bytes) else (e.stderr or "")
+ raise AssertionError("showtime %s did not return in %d s\nstderr: %s\n%s" % (
+ " ".join(map(str, args)), timeout, err[-2000:], _log_tails(args, t0 - 1))) from None
skip_if_listen_refused(cp) # render, snap and check serve the project on a local port
if check and cp.returncode != 0:
raise AssertionError("showtime %s failed (rc=%d):\n%s\n%s" % (
diff --git a/skills/showtime/tests/test_pace.py b/skills/showtime/tests/test_pace.py
index 7186351..6e9781f 100644
--- a/skills/showtime/tests/test_pace.py
+++ b/skills/showtime/tests/test_pace.py
@@ -11,8 +11,9 @@ seeks, and every wait is its fixed value times a factor of 1-5 (never shorter th
(SHOWTIME_TEST_WAIT_SCALE=0.04: a seek gets 2.4 s, as 60 s does on a real machine): with the fixed waits
(SHOWTIME_PACE=0) the render fails on the seek deadline; paced, it renders and render.json records the
factor (5, the ceiling) and the seek cost
- * a page whose ST.waitFor gate takes 3 s of work in 200 ms pieces (scale 0.03: the gate gets 1.8 s): with the
- fixed waits the page never becomes ready; paced, the gaps between its frames raise the factor and it does
+ * a page whose ST.waitFor gate takes 4 s of work in 400 ms pieces from the moment ST.ready() is called (scale
+ 0.03: the gate gets 1.8 s): with the fixed waits the page never becomes ready; paced, the gaps between its
+ frames raise the factor and it does
* the page-open deadline (stagehost openGuarded, SHOWTIME_TEST_OPEN_TIMEOUT shortens it): render's first page
and check's pages are tried once more in a new browser, then the command fails naming the step; a browser
really stopped (SIGSTOP) before check opens its page is killed and check finishes in a new one, and stopped
@@ -152,8 +153,16 @@ class TestSlowPages(unittest.TestCase):
def test_slow_gate_ready_when_paced(self):
proj = self.tmp / "gate"
write(proj / "showtime.json", json.dumps({"width": 320, "height": 180, "fps": 10, "duration": 1, "background": "#202830"}))
+ # The gate's deadline starts when ST.ready() reaches the gates, not when the gate starts. A gate that started
+ # while the page parsed had done some of its work by then, as much as the host's calls between the first
+ # load and ST.ready() took (each waits for a 200 ms piece: 5 on a Mac, 2 more on a busy Windows runner, where
+ # 3 s of work in 200 ms pieces then fit the fixed 1.8 s and the fixed run passed). Started by ST.ready() itself,
+ # one piece is done before its deadline starts on any machine: 4 s of work in 400 ms pieces leaves 3.6 s,
+ # twice the fixed wait, and frames 150-200 ms apart make it x3-4 paced (5.4-7.2 s).
write(proj / "index.html", HEAD + "</head><body><script>" + BUSY_JS +
- "ST.waitFor((async () => { for (let k = 0; k < 15; k++) { busy(200); await new Promise((r) => setTimeout(r, 0)); } })(), 'heavy init');\n"
+ "let go; const started = new Promise((r) => { go = r; });\n"
+ "const ready = ST.ready; ST.ready = function (o) { go(); return ready.call(this, o); };\n"
+ "ST.waitFor(started.then(async () => { for (let k = 0; k < 10; k++) { busy(400); await new Promise((r) => setTimeout(r, 0)); } }), 'heavy init');\n"
"ST.onSeek(() => {});</script></body></html>")
code = """
const S = await import(%s);
@@ -194,7 +203,8 @@ process.exit(0);
self.assertNotEqual(cp.returncode, 0, cp.stdout[-1500:])
self.assertIn("trying once more in a new browser", cp.stderr)
self.assertEqual(cp.stderr.count("trying once more"), 1, cp.stderr[-2000:])
- self.assertRegex(cp.stderr, r"timed out after \d+s: opening the page")
+ # the deadline is x the page's pace (a busy runner's frames raise it while the page waits)
+ self.assertRegex(cp.stderr, r"timed out after \d+s( \(x[\d.]+ for this page's pace\))?: opening the page")
# names the step (on a fast machine the page's own 20 s wait; a slow one may still be setting the tab up)
self.assertRegex(cp.stderr, STUCK_AT)