Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
realtime-bench: the realtime-editing plan's experiments 1, 2 and 3a, measured (docs/realtime.feature)
shinyobjectz4c71a316287d
diff --git a/bench/realtime/cases/caption.tsx b/bench/realtime/cases/caption.tsxnew file mode 100644index 00000000..68475f84--- /dev/null+++ b/bench/realtime/cases/caption.tsx@@ -0,0 +1,20 @@+// HTML over 3D with one control (docs/realtime.feature RT0a): raster.tsx's scene under a caption and a lower third+// drawn by the page, the hero cube's colour a prop. The page's text over 3D is where play and render already differ by+// a level or two (docs/rerender.feature RR1: SSIM >= 0.999473).+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { Scene } from "./scene";++function Caption({ color = "#d04a3a" }: { color?: string }) {+ const f = useCurrentFrame();+ return (+ <AbsoluteFill style={{ background: "#9fb7c8" }}>+ <Scene color={color} />+ <div style={{ position: "absolute", left: 60, bottom: 70, padding: "14px 22px", borderRadius: 10, background: "rgba(12,16,24,0.72)", fontFamily: "Helvetica, Arial, sans-serif", color: "#fff" }}>+ <div style={{ fontSize: 18, letterSpacing: "0.25em", opacity: 0.75 }}>SHOT 1</div>+ <div style={{ fontSize: 44, fontWeight: 700, opacity: Math.min(1, f / 15) }}>The hero cube</div>+ </div>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="caption" component={Caption} defaultProps={{ color: "#d04a3a" }} width={1280} height={720} fps={30} durationInFrames={150} />);diff --git a/bench/realtime/cases/films.tsx b/bench/realtime/cases/films.tsxnew file mode 100644index 00000000..eaeeb347--- /dev/null+++ b/bench/realtime/cases/films.tsx@@ -0,0 +1,19 @@+// The window render's films (docs/realtime.feature RT1; the plan's experiment 2): RR0's six shots (bench/rerender/+// shots.tsx: a procedural set with grass, trees, a room and a street, a look and a camera per 5 s shot) played round+// for 60 s and for 180 s at 1920x1080, 30 fps. window.sh renders the same 5 s window of each, as the app's draft+// renders the seconds around the playhead (`edit={{ segments, scale }}`), so any difference in its cost is the+// length of the film around it.+import { Composition, registerRoot, useCurrentFrame } from "raea";+import { FPS, Frame, SHOT } from "../../rerender/shots";++function Round() {+ const f = useCurrentFrame();+ return <Frame k={Math.floor(f / SHOT) % 6} t={(f % SHOT) / FPS} />;+}++registerRoot(() => (+ <>+ <Composition id="film-60" component={Round} width={1920} height={1080} fps={FPS} durationInFrames={60 * FPS} />+ <Composition id="film-180" component={Round} width={1920} height={1080} fps={FPS} durationInFrames={180 * FPS} />+ </>+));diff --git a/bench/realtime/cases/random.tsx b/bench/realtime/cases/random.tsxnew file mode 100644index 00000000..b3e4db02--- /dev/null+++ b/bench/realtime/cases/random.tsx@@ -0,0 +1,21 @@+// The 2D piece of title.tsx with confetti placed by Math.random and a clock read from Date (docs/realtime.feature+// RT0a): a render seeds Math.random from the composition and dates frame 0 at the render's epoch (sdk/raea/src/pure.ts),+// a live session from its own seed and start (runtime/live/src/lib.rs new_session), so this case says what the seed+// and the epoch alone cost a live frame.+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";++function Confetti({ hue = 210 }: { hue?: number }) {+ const f = useCurrentFrame();+ const dots = Array.from({ length: 40 }, (_, i) => ({ x: Math.random() * 1200, y: Math.random() * 660, r: 8 + Math.random() * 16, h: (hue + i * 9) % 360 }));+ const clock = new Date().getUTCSeconds();+ return (+ <AbsoluteFill style={{ background: `hsl(${hue}, 40%, 18%)` }}>+ {dots.map((d, i) => (+ <div key={i} style={{ position: "absolute", left: d.x, top: (d.y + f * 2) % 700, width: d.r * 2, height: d.r * 2, borderRadius: d.r, background: `hsl(${d.h}, 80%, 60%)` }} />+ ))}+ <div style={{ position: "absolute", right: 40, top: 30, fontFamily: "Helvetica, Arial, sans-serif", fontSize: 40, color: "#fff" }}>{clock}</div>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="random" component={Confetti} defaultProps={{ hue: 210 }} width={1280} height={720} fps={30} durationInFrames={150} />);diff --git a/bench/realtime/cases/raster.tsx b/bench/realtime/cases/raster.tsxnew file mode 100644index 00000000..e63d42b2--- /dev/null+++ b/bench/realtime/cases/raster.tsx@@ -0,0 +1,15 @@+// A raster-lit 3D piece with one control (docs/realtime.feature RT0a): a few parts on a floor under a sun, the camera+// circling them over 5 s, the hero cube's colour a prop. Colour is on the live scene's keyed list+// (runtime/scene/src/live.rs), so a running world takes the change without rebuilding the part.+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Scene } from "./scene";++function Raster({ color = "#d04a3a" }: { color?: string }) {+ return (+ <AbsoluteFill style={{ background: "#9fb7c8" }}>+ <Scene color={color} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="raster" component={Raster} defaultProps={{ color: "#d04a3a" }} width={1280} height={720} fps={30} durationInFrames={150} />);diff --git a/bench/realtime/cases/scene.tsx b/bench/realtime/cases/scene.tsxnew file mode 100644index 00000000..d0b6831b--- /dev/null+++ b/bench/realtime/cases/scene.tsx@@ -0,0 +1,24 @@+// raster.tsx's scene, shared with caption.tsx: a few parts on a floor under a sun, the camera circling them over 5 s,+// the hero cube's colour a prop.+import { useCurrentFrame } from "raea";+import { Camera3d } from "raea/camera";+import { AmbientLight, DirectionalLight } from "raea/light";+import { Cuboid, Mesh3d, Sphere } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Transform } from "raea/transform";++export function Scene({ color = "#d04a3a" }: { color?: string }) {+ const f = useCurrentFrame();+ const a = 0.4 + f * 0.012;+ return (+ <>+ <Camera3d transform={Transform.fromXyz(Math.cos(a) * 6, 2.6, Math.sin(a) * 6).lookingAt([0, 0.6, 0], [0, 1, 0])} projection={{ Perspective: { fov: (45 * Math.PI) / 180 } }} />+ <DirectionalLight name="sun" transform={Transform.fromXyz(4, 8, 3).lookingAt([0, 0, 0], [0, 1, 0])} illuminance={6000} shadow_maps_enabled />+ <AmbientLight brightness={120} />+ <Mesh3d name="floor" transform={Transform.fromXyz(0, -0.05, 0)}><Cuboid half_size={[8, 0.05, 8]} /><StandardMaterial base_color="#a8a196" perceptual_roughness={0.9} /></Mesh3d>+ <Mesh3d name="hero" transform={Transform.fromXyz(0, 0.6, 0)}><Cuboid half_size={[0.6, 0.6, 0.6]} /><StandardMaterial base_color={color} perceptual_roughness={0.45} /></Mesh3d>+ <Mesh3d name="ball" transform={Transform.fromXyz(1.6, 0.45 + 0.25 * Math.abs(Math.sin(f / 9)), 0.8)}><Sphere radius={0.45} /><StandardMaterial base_color="#3a7bd0" perceptual_roughness={0.3} metallic={0.2} /></Mesh3d>+ <Mesh3d name="post" transform={Transform.fromXyz(-1.5, 0.9, -1)}><Cuboid half_size={[0.2, 0.9, 0.2]} /><StandardMaterial base_color="#e2c044" perceptual_roughness={0.7} /></Mesh3d>+ </>+ );+}diff --git a/bench/realtime/cases/solari.tsx b/bench/realtime/cases/solari.tsxnew file mode 100644index 00000000..ca040e85--- /dev/null+++ b/bench/realtime/cases/solari.tsx@@ -0,0 +1,54 @@+// A ray-traced piece with one control (docs/realtime.feature RT0b): a closed room lit by Solari from a glowing panel+// and a sun through a window, the camera dollying in over 5 s, the panel's glow a prop. Solari and MetalFX keep light+// history between updates, so a frame jumped to isn't converged at once: the bench counts the updates a seeked frame+// takes to come within SSIM 0.995 of the render's frame.+import { AbsoluteFill, Composition, registerRoot, useCurrentFrame } from "raea";+import { Camera3d } from "raea/camera";+import { LinearRgba } from "raea/color";+import { DirectionalLight, SolariLighting } from "raea/light";+import { Cuboid, Mesh3d, Sphere } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Transform } from "raea/transform";++type V3 = [number, number, number];+// a 6 x 3 x 6 m room of thick slabs, a window in the east wall+const SLABS: { name: string; min: V3; max: V3; c: string }[] = [+ { name: "floor", min: [-3.2, -0.2, -3.2], max: [3.2, 0, 3.2], c: "#8a7b66" },+ { name: "ceiling", min: [-3.2, 3, -3.2], max: [3.2, 3.2, 3.2], c: "#d8d4c8" },+ { name: "wall-w", min: [-3.2, 0, -3.2], max: [-3, 3, 3.2], c: "#c9bfa4" },+ { name: "wall-n", min: [-3.2, 0, -3.2], max: [3.2, 3, -3], c: "#b9c4cf" },+ { name: "wall-s", min: [-3.2, 0, 3], max: [3.2, 3, 3.2], c: "#c9bfa4" },+ { name: "wall-e1", min: [3, 0, -3.2], max: [3.2, 3, -0.8], c: "#c9bfa4" },+ { name: "wall-e2", min: [3, 0, 0.8], max: [3.2, 3, 3.2], c: "#c9bfa4" },+ { name: "wall-e3", min: [3, 0, -0.8], max: [3.2, 1, 0.8], c: "#c9bfa4" },+ { name: "wall-e4", min: [3, 2.2, -0.8], max: [3.2, 3, 0.8], c: "#c9bfa4" },+];+const mid = (a: V3, b: V3): V3 => [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];+const half = (a: V3, b: V3): V3 => [(b[0] - a[0]) / 2, (b[1] - a[1]) / 2, (b[2] - a[2]) / 2];++function Room({ glow = 600 }: { glow?: number }) {+ const f = useCurrentFrame();+ const z = 2.4 - f * 0.008;+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Camera3d transform={Transform.fromXyz(-1.8, 1.5, z).lookingAt([1.2, 0.9, -1.2], [0, 1, 0])} projection={{ Perspective: { fov: (60 * Math.PI) / 180 } }}>+ <SolariLighting bounces={2} />+ </Camera3d>+ <DirectionalLight name="sun" transform={Transform.fromXyz(10, 6, 1).lookingAt([0, 0, 0], [0, 1, 0])} illuminance={30000} />+ {SLABS.map(({ name, min, max, c }) => (+ <Mesh3d key={name} name={name} transform={Transform.fromXyz(...mid(min, max))}>+ <Cuboid half_size={half(min, max)} />+ <StandardMaterial base_color={c} perceptual_roughness={0.85} />+ </Mesh3d>+ ))}+ <Mesh3d name="panel" castShadow={false} transform={Transform.fromXyz(0, 2.96, -1)}>+ <Cuboid half_size={[0.8, 0.02, 0.4]} />+ <StandardMaterial base_color="#ffffff" emissive={new LinearRgba(glow, glow * 0.95, glow * 0.85, 1)} />+ </Mesh3d>+ <Mesh3d name="table" transform={Transform.fromXyz(0.8, 0.4, -1.2)}><Cuboid half_size={[0.7, 0.4, 0.5]} /><StandardMaterial base_color="#6b4a32" perceptual_roughness={0.6} /></Mesh3d>+ <Mesh3d name="ball" transform={Transform.fromXyz(0.6, 1.1, -1.1)}><Sphere radius={0.3} /><StandardMaterial base_color="#d04a3a" perceptual_roughness={0.4} /></Mesh3d>+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="solari" component={Room} defaultProps={{ glow: 600 }} width={1280} height={720} fps={30} durationInFrames={150} />);diff --git a/bench/realtime/cases/title.tsx b/bench/realtime/cases/title.tsxnew file mode 100644index 00000000..794d84ab--- /dev/null+++ b/bench/realtime/cases/title.tsx@@ -0,0 +1,23 @@+// A 2D piece with one control (docs/realtime.feature RT0a): a title card whose background hue is a prop, its words+// sliding in and a bar filling over 5 s. No 3D, no media, no randomness: its frame is a function of the frame number+// and `hue` alone, so the stage and a render of the same frame and props must be the same pixels.+import { AbsoluteFill, Composition, interpolate, registerRoot, useCurrentFrame } from "raea";++function Title({ hue = 210 }: { hue?: number }) {+ const f = useCurrentFrame();+ const y = interpolate(f, [0, 24], [60, 0], { extrapolateRight: "clamp" });+ const bar = interpolate(f, [0, 150], [0, 1], { extrapolateRight: "clamp" });+ return (+ <AbsoluteFill style={{ background: `hsl(${hue}, 55%, 28%)`, alignItems: "center", justifyContent: "center" }}>+ <div style={{ fontFamily: "Helvetica, Arial, sans-serif", fontSize: 120, fontWeight: 700, color: "#fff", transform: `translateY(${y}px)`, opacity: Math.min(1, f / 18) }}>+ Live controls+ </div>+ <div style={{ position: "absolute", left: 160, right: 160, bottom: 120, height: 14, borderRadius: 7, background: "rgba(255,255,255,0.2)" }}>+ <div style={{ width: `${bar * 100}%`, height: "100%", borderRadius: 7, background: `hsl(${(hue + 160) % 360}, 80%, 62%)` }} />+ </div>+ <div style={{ position: "absolute", left: 160 + bar * 800, top: 140, width: 80, height: 80, borderRadius: 40, background: "#fff", opacity: 0.85, transform: `rotate(${f * 3}deg)` }} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="title" component={Title} defaultProps={{ hue: 210 }} width={1280} height={720} fps={30} durationInFrames={150} />);diff --git a/bench/realtime/stage.mjs b/bench/realtime/stage.mjsnew file mode 100644index 00000000..dbedbf53--- /dev/null+++ b/bench/realtime/stage.mjs@@ -0,0 +1,147 @@+// The stage's side of the realtime bench (bench/realtime/stage.sh): a headless raea window running stage/page.tsx, its+// stage driven over the window's MCP server as the app's useStage drives it. For one case:+// 1. the composition A (its defaultProps as written) shown, paused, seeked to frame N, captured after each of+// UPDATES draws of that frame (a paused stage draws again on a pointer move: one engine update each)+// 2. stage.props {PROP: B} on that running world: the frame drawn again with them (ab), captured the same way, and+// the time from the call to the stage's next painted frame+// 3. the same frame seeked to again, as the app's useStage does after props on a paused stage (abs): the time from+// the props call to the frame it paints, and captures as above+// 4. the copy with B written into defaultProps shown fresh and captured the same way (b)+// Captures are the window's own frame (frame_png), one window point a stage pixel. Writes OUT/{a,ab,abs,b}-K.png and+// OUT/stage.json ({ props_ms, steps, window, scale }).+// node bench/realtime/stage.mjs PORT OUT A.tsx B.tsx PROP VALUE_JSON FRAME W H UPDATES+import { writeFileSync } from "node:fs";++const [port, out, fileA, fileB, prop, valueJson, frameS, wS, hS, updatesS] = process.argv.slice(2);+const N = Number(frameS), W = Number(wS), H = Number(hS), UPDATES = Number(updatesS ?? 3);+const value = JSON.parse(valueJson);+let id = 0;+async function tool(name, args = {}) {+ const r = await fetch(`http://127.0.0.1:${port}/mcp`, {+ method: "POST",+ headers: { "content-type": "application/json", accept: "application/json, text/event-stream" },+ body: JSON.stringify({ jsonrpc: "2.0", id: ++id, method: "tools/call", params: { name, arguments: args } }),+ });+ const j = await r.json();+ if (j.error) throw new Error(`${name}: ${j.error.message}`);+ return j.result;+}+const text = (res) => res?.content?.find((c) => c.type === "text")?.text;+/** a stage host call through the page's one action */+async function stage(name, args) {+ const res = await tool("action", { name: "rt.call", args: { name, args } });+ const t = text(res);+ let v;+ try {+ v = t ? JSON.parse(t) : res;+ } catch {+ // the window's own answer when the page didn't answer in time (a stage busy opening a file): an error, retried+ // by `until`+ throw new Error(`${name}: ${t}`);+ }+ if (v && typeof v === "object" && "error" in v && Object.keys(v).length === 1) throw new Error(`${name}: ${v.error}`);+ return v?.value !== undefined && Object.keys(v).length === 1 ? v.value : v;+}+/** the stage's status, asked again while the page is too busy to answer (up to a minute) */+async function status() {+ const end = Date.now() + 60_000;+ for (;;) {+ try {+ return await stage("stage.status", null);+ } catch (e) {+ if (Date.now() > end) throw e;+ await new Promise((ok) => setTimeout(ok, 50));+ }+ }+}+async function png(file) {+ const res = await tool("frame_png");+ const data = res?.content?.find((c) => c.type === "image")?.data;+ if (!data) throw new Error("frame_png: no image");+ writeFileSync(file, Buffer.from(data, "base64"));+}+const pause = (ms) => new Promise((ok) => setTimeout(ok, ms));+/** until `check` answers, polling the stage's status; the bound is the work's own (an opening can bundle for seconds) */+async function until(what, check, ms) {+ const end = Date.now() + ms;+ for (;;) {+ let s;+ try {+ s = await status();+ } catch (e) {+ if (Date.now() > end) throw e;+ await pause(50);+ continue;+ }+ if (s?.error) throw new Error(`${what}: the stage says ${s.error}`);+ if (check(s)) return s;+ if (Date.now() > end) throw new Error(`${what}: not within ${ms} ms (status ${JSON.stringify(s)})`);+ await pause(5);+ }+}++const result = { case: { fileA, fileB, prop, value, frame: N, size: [W, H] }, steps: [] };+// the draws captured: every one up to 8, then 12, 16, 24, 32, 48, 64, ... and the last+const KS = new Set([...Array.from({ length: Math.min(UPDATES, 9) }, (_, k) => k), ...[12, 16, 24, 32, 48, 64, 96, 128].filter((k) => k < UPDATES), UPDATES - 1]);+/** the frame drawn again `UPDATES` times (k = 0 is the draw that put it there), captured after the draws in KS */+async function captures(tag) {+ for (let k = 0; k < UPDATES; k++) {+ if (k > 0) {+ const was = (await status()).painted;+ await stage("stage.pointer", { x: 1 + (k % 2), y: 1, down: false });+ await until(`${tag} update ${k}`, (s) => s.painted > was, 30_000);+ }+ if (!KS.has(k)) continue;+ // the window composites the stage's newest frame on its next frame: two window frames on, so the capture is it+ await tool("frame_png");+ await png(`${out}/${tag}-${k}.png`);+ console.error(`captured ${tag}-${k}`);+ }+}+async function show(file, tag) {+ const t0 = Date.now();+ // answered once sent; an answer that didn't come back in time (the stage thread opening the last file) is waited+ // out by the status below+ await stage("stage.show", { src: file, w: W, h: H }).catch((e) => console.error(`show: ${e.message}`));+ await until(`${tag} opened`, (s) => s.showing === file && s.painted > 0, 180_000);+ const opened = Date.now() - t0;+ await stage("stage.play", { on: false });+ const was = (await status()).painted;+ await stage("stage.seek", { frame: N });+ const s = await until(`${tag} at ${N}`, (s) => s.frame === N && s.painted > was && !s.playing, 60_000);+ result.steps.push({ tag, opened_ms: opened, frame: s.frame });+ await captures(tag);+}++try {+ const state = JSON.parse(text(await tool("state")) ?? "{}");+ result.window = state.window ?? null;+ result.scale = state.scale ?? null;+ await show(fileA, "a");+ // the props on the running world: from the call to the stage's next painted frame+ const was = (await status()).painted;+ const t0 = performance.now();+ const answer = await stage("stage.props", { props: { [prop]: value } });+ const answered = performance.now() - t0;+ await until("props drawn", (s) => s.painted > was, 30_000);+ result.props_ms = { answered: Math.round(answered), painted: Math.round(performance.now() - t0), answer };+ await captures("ab");+ // props, then the frame seeked to again behind them (the app sends the seek without waiting for the props' answer;+ // here it follows the answer, so the time is an upper bound by one round trip)+ const was2 = (await status()).painted;+ const t1 = performance.now();+ await stage("stage.props", { props: { [prop]: value } });+ await stage("stage.seek", { frame: N });+ await until("props and seek drawn", (s) => s.painted >= was2 + 2 && s.frame === N, 30_000);+ result.props_seek_ms = Math.round(performance.now() - t1);+ await captures("abs");+ await show(fileB, "b");+ result.ok = true;+} catch (e) {+ result.ok = false;+ result.error = String(e?.message ?? e);+ console.error(`FAIL ${result.error}`);+}+writeFileSync(`${out}/stage.json`, JSON.stringify(result, null, 1));+console.log(JSON.stringify({ ok: result.ok, props_ms: result.props_ms, props_seek_ms: result.props_seek_ms, steps: result.steps, window: result.window, scale: result.scale, error: result.error }));+process.exit(result.ok ? 0 : 1);diff --git a/bench/realtime/stage.sh b/bench/realtime/stage.shnew file mode 100644index 00000000..650bda3a--- /dev/null+++ b/bench/realtime/stage.sh@@ -0,0 +1,95 @@+#!/bin/bash+# Is the live frame the render's frame? (docs/realtime.feature RT0a, RT0b; the plan's experiment 1.) For each case: the+# composition shown on the engine's stage in a headless raea window, paused on frame N, then one control changed with+# stage.props on that running world; against `raea render --frame N` of the same file and of the copy with the new+# value written into its defaultProps. SSIM (ffmpeg's, over RGB) between:+# a the stage on the file as written and its render: the stage against the render, no change+# ab the stage after stage.props {PROP: B} and the copy's render: a props change on the running world+# abs the same, the frame then seeked to again (what the app sends after props on a paused stage), and the+# copy's render: what experiment 1 measures; and against the copy shown fresh on the stage+# b the copy shown fresh and the copy's render+# each after every one of UPDATES draws of the frame (k = 0 is the draw the seek or the props made): a ray-traced+# frame's history converges over draws, and the first k at SSIM >= 0.995 is reported. A row:+# FILE PROP A B FRAME UPDATES [SEED|-] [seq] (B as JSON; SEED: RAEA_SEED for the window, so a live session takes+# the render's seed; seq: also against frame N of a run rendering 0 to N;+# rows from RT_ROWS, default bench/realtime/stage.tsv)+# bash bench/realtime/stage.sh [ROW-SUBSTRING...] RAEA_BIN, RAEA_PAGE_HOST_BIN: the binaries (target/release's);+# RT_OUT: where pictures go; RT_PORT: the window's MCP port (7631)+# Headless only: the window is raea-page-host without --window, on its own port, its sound off.+cd "$(dirname "$0")/../.." || exit 2+ROOT=$PWD+export RAEA_SIGN=0 RAEA_MARK=0 RAEA_AUDIO_MUTE=1 RAEA_HOME=$ROOT+BIN=${RAEA_BIN:-$ROOT/target/release/raea}+HOST=${RAEA_PAGE_HOST_BIN:-$ROOT/target/release/raea-page-host}+ROWS=${RT_ROWS:-$ROOT/bench/realtime/stage.tsv}+PORT=${RT_PORT:-7631}+OUT=${RT_OUT:-$(mktemp -d "${TMPDIR:-/tmp}/raea-rt-stage.XXXXXX")}+mkdir -p "$OUT"+bun "$ROOT/bench/realtime/stage/build.ts" "$OUT/page.js" || { echo "FAIL the stage page didn't build"; exit 1; }+ssim() { ffmpeg -nostdin -hide_banner -nostats -i "$1" -i "$2" -lavfi "[0:v]format=rgb24[a];[1:v]format=rgb24[b];[a][b]ssim" -f null - 2>&1 | grep -o 'All:[0-9.]*' | cut -d: -f2; }+dim() { grep '<Composition' "$1" | head -1 | grep -oE "$2=\{[0-9]+\}" | head -1 | tr -dc 0-9; }+host=""+copies=()+stop() {+ [ -n "$host" ] && kill "$host" 2>/dev/null+ for c in "${copies[@]+"${copies[@]}"}"; do rm -f -- "$c"; done+}+trap stop EXIT+pass=0 fail=0+while IFS=$'\t' read -r path prop a b frame updates seed seq; do+ [[ -z $path || $path == \#* ]] && continue+ if [ $# -gt 0 ]; then hit=0; for s in "$@"; do [[ $path == *"$s"* ]] && hit=1; done; [ $hit = 1 ] || continue; fi+ [[ $path == /* ]] && src=$path || src=$ROOT/$path+ [ "$seed" = - ] && seed=""+ slug=$(basename "$src" .tsx)${seed:+-seed}+ dir=$OUT/$slug && rm -rf "${dir:?}" && mkdir -p "$dir"+ w=$(dim "$src" width); h=$(dim "$src" height)+ # the copy with B written into its defaultProps, beside the file (its imports resolve as the file's): as an edit's+ # draft is written (the app's host/draft.ts), and removed when this ends+ copy=$(dirname "$src")/.rt-$slug-b.tsx+ copies+=("$copy")+ PROP=$prop A=$a B=$b perl -0pe 's/(defaultProps=\{\{[^}]*\b\Q$ENV{PROP}\E:\s*)\Q$ENV{A}\E/$1$ENV{B}/' "$src" > "$copy"+ if cmp -s "$src" "$copy"; then echo "FAIL $path: couldn't write $prop: $b into its defaultProps"; fail=$((fail + 1)); continue; fi+ # the renders: the frame alone, in a process of its own (a still: `render --frame N`); with seq also frames 0 to N+ # in one run (`--at 0,...,N`), frame N as a film's render reaches it, one update a frame+ for v in a b; do+ f=$src; [ $v = b ] && f=$copy+ t0=$(perl -MTime::HiRes=time -e 'printf "%.3f", time')+ (cd "$(dirname "$src")" && RAEA_READBACK=rgba "$BIN" render "$f" --frame "$frame" -o "$dir/render-$v.png") > "$dir/render-$v.log" 2>&1 || echo "note $path: render $v exited 1 (its checks found errors; the picture is still compared): $(grep -m1 -E "^raea: error" "$dir/render-$v.log" | cut -c1-160)"+ [ -f "$dir/render-$v.png" ] || { echo "FAIL $path: render $v: $(grep -m1 -E 'REFUSED|error' "$dir/render-$v.log" | cut -c1-200)"; fail=$((fail + 1)); continue 2; }+ echo "render-$v $(perl -MTime::HiRes=time -e "printf '%.2f', time - $t0") s" >> "$dir/times.txt"+ if [ "$seq" = seq ]; then+ (cd "$(dirname "$src")" && RAEA_READBACK=rgba "$BIN" render "$f" --at "$(seq 0 "$frame" | paste -sd, -)" -o "$dir/seq-$v/") > "$dir/seq-$v.log" 2>&1+ [ -f "$dir/seq-$v/$(printf "frame-%05d.png" "$frame")" ] || { echo "FAIL $path: sequence render $v"; fail=$((fail + 1)); continue 2; }+ cp "$dir/seq-$v/$(printf 'frame-%05d.png' "$frame")" "$dir/film-$v.png"+ rm -rf "${dir:?}/seq-$v"+ fi+ done+ echo "rendered $path frame $frame: $(tr '\n' ' ' < "$dir/times.txt")"+ # the window: one window point a stage pixel, the stage at the composition's size+ [ -n "$host" ] && kill "$host" 2>/dev/null && wait "$host" 2>/dev/null+ if lsof -nP -iTCP:"$PORT" -sTCP:LISTEN -t >/dev/null; then echo "FAIL port $PORT is in use (RT_PORT)"; exit 1; fi+ ( [ -n "$seed" ] && export RAEA_SEED=$seed; RAEA_PAGE_MCP_PORT=$PORT exec "$HOST" "$OUT/page.js" --size "${w}x$h" ) > "$dir/page.log" 2>&1 &+ host=$!+ curl -s --retry 120 --retry-connrefused --retry-delay 1 --retry-max-time 120 -o /dev/null "http://127.0.0.1:$PORT/" || { echo "FAIL $path: the window didn't start: $(tail -2 "$dir/page.log")"; exit 1; }+ # its progress a line a capture on stderr (kept in stage.err), so a long converging row is seen moving+ if ! node "$ROOT/bench/realtime/stage.mjs" "$PORT" "$dir" "$src" "$copy" "$prop" "$b" "$frame" "$w" "$h" "${updates:-3}" > "$dir/stage.out" 2> >(tee "$dir/stage.err" >&2); then+ echo "FAIL $path: the stage: $(grep -m1 FAIL "$dir/stage.err" | cut -c1-240)"; fail=$((fail + 1)); continue+ fi+ # each capture against the renders: columns k, a~render-a, ab~render-b, abs~render-b, abs~b, b~render-b, and with+ # seq a~film-a, abs~film-b, b~film-b+ for k in $(ls "$dir" | sed -n 's/^a-\([0-9]*\)\.png$/\1/p' | sort -n); do+ row="$k\t$(ssim "$dir/a-$k.png" "$dir/render-a.png")\t$(ssim "$dir/ab-$k.png" "$dir/render-b.png")\t$(ssim "$dir/abs-$k.png" "$dir/render-b.png")\t$(ssim "$dir/abs-$k.png" "$dir/b-$k.png")\t$(ssim "$dir/b-$k.png" "$dir/render-b.png")"+ [ "$seq" = seq ] && row="$row\t$(ssim "$dir/a-$k.png" "$dir/film-a.png")\t$(ssim "$dir/abs-$k.png" "$dir/film-b.png")\t$(ssim "$dir/b-$k.png" "$dir/film-b.png")"+ echo -e "$row" >> "$dir/ssim.tsv"+ done+ # the first draw at which a column comes within 0.995 and 1.000000, and its value at the first and last draw+ first() { awk -F'\t' -v c="$1" -v t="$2" '$c + 0 >= t { print $1; f = 1; exit } END { if (!f) print "never" }' "$dir/ssim.tsv"; }+ ends() { awk -F'\t' -v c="$1" 'NR == 1 { a = $c } { z = $c; k = $1 } END { printf "%s (k0) .. %s (k%s)", a, z, k }' "$dir/ssim.tsv"; }+ ms=$(node -e 'const r=require(process.argv[1]); console.log(`${r.props_ms ? r.props_ms.painted : "none"} ms, props+seek->painted ${r.props_seek_ms ?? "none"} ms`)' "$dir/stage.json")+ echo "ROW $path${seed:+ (seed $seed)} $prop=$b frame $frame: stage~render a $(ends 2); props alone ab $(ends 3); props+seek abs $(ends 4) (>= 0.995 at k=$(first 4 0.995), 1 at k=$(first 4 1)); abs~fresh b $(ends 5); fresh b $(ends 6) (>= 0.995 at k=$(first 6 0.995)); props->painted $ms"+ [ "$seq" = seq ] && echo "ROW $path against the film's frame (render --at 0..$frame): a $(ends 7); abs $(ends 8) (>= 0.995 at k=$(first 8 0.995)); fresh b $(ends 9) (>= 0.995 at k=$(first 9 0.995))"+ pass=$((pass + 1))+done < "$ROWS"+echo "stage = render: $pass rows measured, $fail failed (out: $OUT)"+[ $fail = 0 ]diff --git a/bench/realtime/stage.tsv b/bench/realtime/stage.tsvnew file mode 100644index 00000000..989e11bb--- /dev/null+++ b/bench/realtime/stage.tsv@@ -0,0 +1,15 @@+# The realtime bench's stage rows (stage.sh): a composition with one control in its defaultProps, the value it is+# changed to on the running stage, the frame compared and how many draws of it are captured. Tab-separated:+# path the composition, from the repo root (or absolute: a copy outside the repo)+# prop the control, a key of its <Composition defaultProps>+# a its value as written (as the source spells it)+# b the value set with stage.props, as JSON (and written into the copy's defaultProps as spelled)+# frame the frame compared+# updates draws of the frame captured (1 for a frame drawn at once; many for ray-traced light converging)+# seed optional: RAEA_SEED for the window, so the live session takes the render's seed+bench/realtime/cases/title.tsx hue 210 30 75 3+bench/realtime/cases/random.tsx hue 210 30 75 2+bench/realtime/cases/random.tsx hue 210 30 75 2 340724834+bench/realtime/cases/raster.tsx color "#d04a3a" "#3ac06a" 75 4+bench/realtime/cases/caption.tsx color "#d04a3a" "#3ac06a" 75 4+bench/realtime/cases/solari.tsx glow 600 2400 75 65 - seqdiff --git a/bench/realtime/stage/build.ts b/bench/realtime/stage/build.tsnew file mode 100644index 00000000..b4fd9b92--- /dev/null+++ b/bench/realtime/stage/build.ts@@ -0,0 +1,36 @@+// The stage page (page.tsx) bundled for raea-page-host as ui-parity bundles a case's Bevy side+// (sdk/ui/parity/build.ts): @raea/ui from the tree, React DOM swapped for its adapter, parity's one React.+// bun bench/realtime/stage/build.ts OUT.js+import { join } from "node:path";++const here = import.meta.dir;+const parity = join(here, "../../../sdk/ui/parity");+const mods = join(parity, "node_modules");+const ui = join(here, "../../../sdk/ui/src");+const out = process.argv[2];+if (!out) {+ console.error("usage: bun build.ts OUT.js");+ process.exit(2);+}+const b = await Bun.build({+ entrypoints: [join(here, "page.tsx")],+ target: "browser",+ format: "iife",+ minify: { syntax: true },+ define: { "process.env.NODE_ENV": '"production"' },+ plugins: [+ {+ name: "rt-stage",+ setup(b) {+ b.onResolve({ filter: /^react-dom(\/client)?$/ }, () => ({ path: join(parity, "probe/react-dom-bevy.ts") }));+ b.onResolve({ filter: /^@raea\/ui(\/.*)?$/ }, (a) => ({ path: join(ui, (a.path.slice("@raea/ui/".length) || "index") + ".ts") }));+ b.onResolve({ filter: /^(react|react-dom|react-reconciler|scheduler)(\/.*)?$/ }, (a) => ({ path: Bun.resolveSync(a.path, mods + "/") }));+ },+ },+ ],+});+if (!b.success) {+ console.error(b.logs.map((l) => String(l)).join("\n"));+ process.exit(1);+}+await Bun.write(out, await b.outputs[0].text());diff --git a/bench/realtime/stage/page.tsx b/bench/realtime/stage/page.tsxnew file mode 100644index 00000000..cf68fafa--- /dev/null+++ b/bench/realtime/stage/page.tsx@@ -0,0 +1,24 @@+// The page the realtime bench drives (bench/realtime/stage.sh): nothing but the engine's stage, its image filling the+// window at one window point a stage pixel, so a capture of the window is the stage's own frame. One action,+// `rt.call {name, args}`, makes any stage host call (engine/page/stage: stage.show, stage.seek, stage.props, ...) and+// answers what it answered, so a driver outside the page plays the stage as the app's useStage does.+import "@raea/ui/dom-globals";+import { mount } from "@raea/ui/react";+import { call, emit, on } from "@raea/ui/wire";++emit("actions", [{ name: "rt.call", about: "a stage host call: {name, args}", args: {} }]);+on<{ id: number; name: string; args?: { name: string; args?: unknown } }>("action", ({ id, name, args }) => {+ if (name !== "rt.call" || !args?.name) return emit("actionDone", { id, error: `no action ${name}` });+ call(args.name, args.args ?? null).then(+ (value) => emit("actionDone", { id, value: value === undefined ? null : JSON.parse(JSON.stringify(value)) }),+ (e: unknown) => emit("actionDone", { id, error: String((e as Error)?.message ?? e) }),+ );+});++mount(+ <div style={{ position: "absolute", left: 0, top: 0, width: "100%", height: "100%", margin: 0, background: "#000" }}>+ <img data-raea-stage="" data-testid="stage" alt="" style={{ position: "absolute", left: 0, top: 0, width: "100%", height: "100%" }} />+ </div>,+ undefined,+ { dom: true },+);diff --git a/bench/realtime/window.sh b/bench/realtime/window.shnew file mode 100644index 00000000..8bab8732--- /dev/null+++ b/bench/realtime/window.sh@@ -0,0 +1,69 @@+#!/bin/bash+# Does a window render cost the window or the whole film? (docs/realtime.feature RT1; the plan's experiment 2.) For each+# row: a copy of the film with `edit={{ segments: [[FROM, TO]], scale: SCALE }}` on its composition, as the app's+# host/draft.ts writes the seconds around the playhead, rendered as the host renders a draft (`raea render COPY -o+# OUT.mp4 --quality draft`, from the film's folder) with RAEA_SIGN=0, RAEA_EXPORT_CACHE=0 (a draft is a file never+# rendered before: the export cache can't have it) and RAEA_STARTUP_TRACE=1 RAEA_BAKE_TRACE=1:+# cold RAEA_BUNDLE_CACHE=0 as well: bundled afresh, as a draft's new file is+# warm the same copy again with its bundle cached, RUNS times (2)+# signed once more as the host runs it, signing on (no RAEA_SIGN or RAEA_MARK), by RAEA_SIGNED_BIN (default+# RAEA_BIN; the public raea has signing's seam and no signer, so pass the build the app runs), then the+# file searched for a C2PA manifest (its "c2pa" JUMBF label), beside the cold run's; RT_VERIFY, a command,+# also reads both. Only rows with `sign`: each signing is one call to the signer, which counts them+# One line a run: wall seconds, the startup marks after the process began (bundled, the first frame, the 3D restart+# and its first frame), the frame time raea reports, the video's frames and seconds (ffprobe), and RAEA_BAKE_TRACE's+# line when a bake ran (none did on 11-16: a draft's fed render steps only its window's frames). A row:+# FILE COMPOSITION FROM TO SCALE [sign] (rows from RT_WINDOW_ROWS, default bench/realtime/window.tsv)+# bash bench/realtime/window.sh [ROW-SUBSTRING...] RAEA_BIN: the raea to run; RT_OUT: where videos go+cd "$(dirname "$0")/../.." || exit 2+ROOT=$PWD+export RAEA_AUDIO_MUTE=1 RAEA_HOME=$ROOT RAEA_EXPORT_CACHE=0 RAEA_STARTUP_TRACE=1 RAEA_BAKE_TRACE=1+BIN=${RAEA_BIN:-$ROOT/target/release/raea}+ROWS=${RT_WINDOW_ROWS:-$ROOT/bench/realtime/window.tsv}+RUNS=${RUNS:-2}+OUT=${RT_OUT:-$(mktemp -d "${TMPDIR:-/tmp}/raea-rt-window.XXXXXX")}+mkdir -p "$OUT"+copies=()+trap 'for c in "${copies[@]+"${copies[@]}"}"; do rm -f -- "$c"; done' EXIT+now() { perl -MTime::HiRes=time -e 'printf "%.3f", time'; }+# one render, timed; prints its line+run() {+ local tag=$1 copy=$2 comp=$3 out=$4 log=$5; shift 5+ local t0 t1+ t0=$(now)+ (cd "$(dirname "$copy")" && env "$@" "$BIN" render "$copy" --composition "$comp" -o "$out" --quality draft) > "$log" 2>&1+ local rc=$?+ t1=$(now)+ # the startup marks, in seconds after the process's first ("main")+ local marks+ marks=$(awk '/^raea startup:/ { t = $3; sub(/^raea startup: [0-9.]+ ms /, ""); sub(/ \(gpu.*/, ""); if (!t0) t0 = t; printf "%s %.2f s; ", $0, (t - t0) / 1000 }' "$log")+ local per frames secs+ per=$(grep -oE '\([0-9.]+ ms a frame' "$log" | head -1 | tr -dc '0-9.')+ frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of csv=p=0 "$out" 2>/dev/null)+ secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out" 2>/dev/null)+ local bake+ bake=$(grep -m1 '^raea bake:' "$log" | sed 's/^raea bake: //')+ printf '%s\texit %s\t%.2f s\t%s ms a frame\t%s frames, %s s of video\tbake: %s\tstartup: %s\n' "$tag" "$rc" "$(echo "$t1 - $t0" | bc)" "${per:-?}" "${frames:-?}" "${secs:-?}" "${bake:-none}" "$marks"+}+while IFS=$'\t' read -r path comp from to scale sign; do+ [[ -z $path || $path == \#* ]] && continue+ if [ $# -gt 0 ]; then hit=0; for s in "$@"; do [[ "$path $comp" == *"$s"* ]] && hit=1; done; [ $hit = 1 ] || continue; fi+ [[ $path == /* ]] && src=$path || src=$ROOT/$path+ slug=$comp+ dir=$OUT/$slug && rm -rf "${dir:?}" && mkdir -p "$dir"+ copy=$(dirname "$src")/.rt-window-$slug.tsx+ copies+=("$copy")+ COMP=$comp EDIT="edit={{ segments: [[$from, $to]], scale: $scale }} " perl -pe 's/(<Composition id="\Q$ENV{COMP}\E" )/$1$ENV{EDIT}/' "$src" > "$copy"+ if cmp -s "$src" "$copy"; then echo "FAIL $path: no <Composition id=\"$comp\" to give the window"; continue; fi+ echo "ROW $path #$comp window [$from, $to) at scale $scale"+ run cold "$copy" "$comp" "$dir/cold.mp4" "$dir/cold.log" RAEA_SIGN=0 RAEA_BUNDLE_CACHE=0+ for ((i = 1; i <= RUNS; i++)); do run "warm$i" "$copy" "$comp" "$dir/warm$i.mp4" "$dir/warm$i.log" RAEA_SIGN=0; done+ if [ "$sign" = sign ]; then+ BIN=${RAEA_SIGNED_BIN:-$BIN} run signed "$copy" "$comp" "$dir/signed.mp4" "$dir/signed.log" -u RAEA_SIGN -u RAEA_MARK+ for v in cold signed; do+ n=$(LC_ALL=C grep -a -c c2pa "$dir/$v.mp4")+ echo "credentials $v: $([ "${n:-0}" -gt 0 ] && echo "a C2PA manifest" || echo none)${RT_VERIFY:+; $($RT_VERIFY "$dir/$v.mp4" 2>&1 | head -c 400)}"+ done+ fi+done < "$ROWS"+echo "videos and logs in $OUT"diff --git a/bench/realtime/window.tsv b/bench/realtime/window.tsvnew file mode 100644index 00000000..856d33b0--- /dev/null+++ b/bench/realtime/window.tsv@@ -0,0 +1,5 @@+# The window render's rows (window.sh): a film, its composition, the window drawn ([from, to) of its own frames) and+# the scale it's drawn at, as the app's host/draft.ts makes a draft of the seconds around the playhead (a long side of+# 960 px). `sign`: one more run with signing on, its Content Credentials read. Tab-separated.+bench/realtime/cases/films.tsx film-60 900 1050 0.5 sign+bench/realtime/cases/films.tsx film-180 900 1050 0.5diff --git a/bench/render-play/rows.tsv b/bench/render-play/rows.tsvindex 9abdf51a..3c768a59 100644--- a/bench/render-play/rows.tsv+++ b/bench/render-play/rows.tsv@@ -24,3 +24,9 @@ bench/bridge/engine3d.tsx - 0.3 0.9 1.25sdk/raea/bench/bevy/pick3d/edit.tsx script:bench/render-play/pick3d.json 0.1 0.2 0.3 0.4 0.6 0.9sdk/r3f/test/live/pointer.tsx script:sdk/r3f/test/live/pointer.json 0.2 0.4 0.6 0.9sdk/raea/bench/bevy/appscreen/edit.tsx script:bench/render-play/appscreen.json 0.2 0.4 0.6 0.9+# Compositions with a control in their defaultProps (docs/realtime.feature RT0a): a 2D card, a raster-lit 3D scene and+# the same under a page caption, each played live and rendered (bench/realtime/stage.sh checks a control changed on+# the engine's stage against the render)+bench/realtime/cases/title.tsx - 0.5 1.5 2.5+bench/realtime/cases/raster.tsx - 0.5 1.5 2.5+bench/realtime/cases/caption.tsx - 0.5 1.5 2.5 the caption's page over 3D is 0.999998 here and 0.999999 on the stage (11-16): the plan's bar for HTML over 3D is 0.9994diff --git a/bench/render-play/run.sh b/bench/render-play/run.shindex f0101aae..109d7ab9 100755--- a/bench/render-play/run.sh+++ b/bench/render-play/run.sh@@ -3,7 +3,9 @@# input, snapshotted at its moments, and the input the play logged (--input-log) is rendered at the same frames# (render --input); the two pictures are compared by SSIM. A row passes at 1.000000 on every frame, or, when rows.tsv# explains it, at >= 0.999. One line a row (PASS, EXPLAINED or FAIL, each frame's SSIM), then a tally; exits 1 on a FAIL.-# bench/render-play/run.sh [ROW-SUBSTRING...] (RAEA_BIN: the raea to run, default target/release/raea)+# bench/render-play/run.sh [ROW-SUBSTRING...] (RAEA_BIN: the raea to run, default target/release/raea; RAEA_RP_ROWS:+# rows from another file, whose paths may be absolute: copies kept+# outside the repo)# A play keeps stepping to its snapshots' frames however loaded the machine (ovw), so an unreached frame is a failure.cd "$(dirname "$0")/../.." || exit 2ROOT=$PWD@@ -20,7 +22,7 @@ pass=0 explained=0 fail=0while IFS=$'\t' read -r path input secs why; do[[ -z $path || $path == \#* ]] && continueif [ $# -gt 0 ]; then hit=0; for s in "$@"; do [[ $path == *"$s"* ]] && hit=1; done; [ $hit = 1 ] || continue; fi- src=$ROOT/$path+ [[ $path == /* ]] && src=$path || src=$ROOT/$pathslug=$(echo "$path" | tr '/' '_' | sed 's/\.tsx$//')w=$(dim "$src" width); w=${w:-$(const "$src" 'CW|VW')}; w=${w:-1920}h=$(dim "$src" height); h=${h:-$(const "$src" 'CH|VH')}; h=${h:-1080}@@ -63,6 +65,6 @@ while IFS=$'\t' read -r path input secs why; doelseecho "FAIL $path:$line (worst $worst; play and renders in $OUT)"; fail=$((fail + 1))fi-done < bench/render-play/rows.tsv+done < "${RAEA_RP_ROWS:-bench/render-play/rows.tsv}"echo "render = play: $pass at 1.000000, $explained explained, $fail failed (out: $OUT)"[ $fail = 0 ]diff --git a/docs/realtime.feature b/docs/realtime.featurenew file mode 100644index 00000000..33aaed28--- /dev/null+++ b/docs/realtime.feature@@ -0,0 +1,183 @@+@spec+Feature: Realtime editing: a composition's controls change the live frame, then the render around it+ The founder, 11-16, on the realtime-editing plan (kept with his project notes, not in this repo): build it in full,+ validate it and optimise it, and include that timeline playback of plain pre-rendered videos is choppy and repeats+ itself. The plan, in short: a composition declares its controls (SDK `controls`); dragging one changes the engine's+ live stage at once (the stage is engine/page/stage, a raea_runtime_live::Live in the app's window), and on release a+ draft of the seconds around the playhead is rendered (the app's host/draft.ts: `edit={{ segments, scale }}`) and+ played in place of the live frame. Phases:+ P1 (0.1.6) controls with a live frame. Drag to the first changed pixel p50 <= 120 ms, p95 <= 200 ms for 2D and+ raster 3D at 1080p (<= 250 ms ray-traced at half size); release to a buffered window <= 3 s for 2D, <= 6 s+ ray-traced at half size; the stage against `raea render --frame N` at SSIM 1.000000 for 2D and raster,+ >= 0.9994 for HTML over 3D; no draft left running for a value that has passed.+ P2 (0.1.7) smart buffering. A buffered window <= 1.5 s for 2D, <= 3 s ray-traced; a trim costs no render; frames+ redrawn = frames that read the control; a structural edit shows in <= 1.3 s with no stall; no mismatch in a+ 1,000-frame audit.+ P3 live playback at 90% of the frame rate, a converged ray-traced frame when paused, keyframed controls, live+ sound within 1 LU of the export, exports reusing cached segments (docs/rerender.feature RR4).+ The founder's answers to the plan's questions (11-16):+ 1. A composition's knobs are "Controls". The workspace's controllers keep their name.+ 2. A live frame that isn't exact is shown labelled while paused or dragging; during playback the last exact frame+ is held.+ 3. Drafts may skip Content Credentials while they stay on the machine; anything that leaves it is signed, and that+ guard is tested.+ 4. Agents declare controls in P1. "Make this a control" (promote a literal the person points at) goes in only if+ RT2 finds fewer than half of notes are value-only.+ 5. Review links stay watch-and-comment.++ Status, 11-16: the plan's experiments 1, 2 and 3a are measured; nothing of P1 is built. On the realtime-bench lane:+ bench/realtime/stage.sh (a headless raea window driven over its own MCP port: a composition shown on the stage,+ paused, a control changed, the frame captured after each draw, against renders), bench/realtime/window.sh (a draft+ window rendered as the host renders one, cold and warm, then once with signing on) and their cases+ (bench/realtime/cases: a 2D card, a raster scene, the same under an HTML caption, a Solari room, a card reading+ Math.random and Date, and 60 s and 180 s films of RR0's six shots), plus render = play rows for the 2D, raster and+ caption cases in bench/render-play/rows.tsv. run.sh takes RAEA_RP_ROWS (rows from another file, absolute paths+ allowed), and stage.sh RT_ROWS and window.sh RT_WINDOW_ROWS the same way, so copies of private films are measured+ from outside the repo; the private rows aren't kept here. Every number was taken on the M5 Pro Mac with other+ sessions' renders and builds running (antsy board), so times are upper bounds and spread wide; SSIM is ffmpeg's over+ RGB24, as bench/render-play/run.sh takes it.++ measured how result+ 2D card: stage = render stage.sh title row, frame 75, hue 210 -> 30 1.000000 before and after the change+ raster scene: stage = render stage.sh raster row, colour changed 1.000000+ HTML caption over 3D: stage = render stage.sh caption row 0.999999 (bar 0.9994)+ props on a paused stage, no seek after the same rows, stage.props alone not drawn: 0.697 2D, 0.986 raster and+ caption, against the new render+ props, then seek N (what the app sends) the same rows drawn at the first draw, = render+ props -> painted MCP round trips to the window (an upper bound) 115-230 ms 2D, 117 ms raster, 398 ms+ caption+ props + seek -> painted the same 160 ms 2D, 171 ms raster, 541 ms caption+ stage.show -> first paint the same 0.8-1.1 s 2D; 4.8-20 s Solari+ Math.random + Date card: stage = render stage.sh random row, the window's own seed 0.928677+ the same, the window on the render's seed RAEA_SEED=seedOf(id), 340724834 0.998346 (the rest: Date's start)+ render = play: 2D, raster, caption run.sh rows, frames 15, 45, 75 1.000000, 1.000000, 0.999998+ render = play: a 90 s raster film (a private run.sh, RAEA_RP_ROWS, frames 15 and 45; the play's 0.945446, 0.945121; each side repeats+ copy, 2160x1080, the paint look) seed replayed in the render (--input) itself at 1.000000 over two runs+ the same, the paint look's wind set to 0 the copy with wind={0} 0.997021, 0.992958 (the rest: willows,+ trunks, far edges)+ the same film on the stage against its still stage.sh, RT_ROWS, frame 45, a gooseScale control 0.943171 at every draw, before and after+ (its change doesn't show at frame 45)+ render = play: a skinned 1080p animatic (copy) run.sh not measured: it throws at frame 0 on+ main ("Model: graph has at most 16 nodes")+ Solari: stage after a seek, against the film's stage.sh solari row, frame 75, 65 draws, against 0.952 (draw 0), 0.9926 (24), 0.9934+ own frame `render --at 0..75` (32), 0.9942 (64): never 0.995+ Solari: two renders of one film frame render --at 0..75 twice 0.996778 (the floor)+ Solari: a still against the film's frame render --frame 75 against render --at 0..75 0.905443+ Solari: the stage against a still the solari row against render --frame 75 0.975 (draw 0) falling to 0.909 (64)+ window render, 60 s film (raster, 1920x1080) window.sh film-60: [900, 1050) at 0.5, 9 runs 10.2-15.2 s, median 12.6 s; 41-67 ms a+ frame+ window render, 180 s film window.sh film-180: the same window, 9 runs, 9.2-20.1 s, median 15.9 s; the 60 s+ alternated with the 60 s film's film's x0.80-1.52 in the same pair,+ median x1.14, x0.86-0.91 when quietest+ warm startup (bundle cached) to the 3D frame RAEA_STARTUP_TRACE marks, 6 runs 2.05-3.71 s, median 2.5 s: ~1.0 s to a+ first 2D frame, a restart with 3D, ~1.0 s+ to its first frame+ the clipping check, a draft RAEA_TIMES 0.45-1.20 s+ window render, the 90 s raster film (copy) window.sh, [1350, 1500) at 0.4444 (960 wide) 35.1 s cold, 25.7 and 22.6 s warm; 140-206+ ms a frame (exit 1 on its clip checks)+ a draft signed? the public raea window.sh, once with RAEA_SIGN unset never: it has the seam and no signer+ a draft signed? the signed build (this Mac's RAEA_SIGNED_BIN, its manifest read yes: Trusted Content Credentials; 10.2 s+ raea) against 7.0-7.5 s unsigned (one run)+ notes that are value-only the last 30 timestamped notes on composition films 8 of 30 (27%); at most 11 (37%)++ What each experiment does to the plan:+ RT0 (experiment 1). The bench's 2D and raster cases are 1.000000 on the stage and in render = play, and the+ Math.random/Date card misses only by its seed and start, which P1's "the render's seed and epoch on the stage"+ covers. But a real raster film misses for a cause other than the seed: the 90 s goose film plays at 0.945+ against its render, the play's seed replayed (the paint look's wind in the grass, then willows and far edges).+ So the branch is taken: live frames are labelled "Preview" everywhere, and the warm worker moves into P1.+ Solari needs more than 30 draws and never reaches 0.995 in 65, so ray-traced previews draw without Solari.+ And a paused stage doesn't draw props without a seek after them (P1's "drawn on a paused stage without a+ re-seek" is needed; the app's re-seek works meanwhile).+ RT1 (experiment 2). The window costs the window, not the film: alternated with the 60 s film's, the 180 s film's+ took a median 1.14 times as long (0.86-0.91 in the quietest pair; 1.52 once, under load), so that half of the+ branch isn't taken. Warm startup tops 2 s (median 2.5 s, of which ~1 s is starting again once the first frame+ meets 3D), so the warm worker moves into P1. A draft from the signed build is signed, so unsigned previews are+ a P1 decision, already made by answer 3. And a 5 s window at half size took 9-20 s (23-35 s for the goose film)+ against P1's 3 s for 2D and 6 s ray-traced: the warm worker is needed for the target, not only for startup.+ RT2 (experiment 3a). Fewer than half the notes are value-only (at most 37%), so background reopen moves into P1,+ and by answer 4 so does "make this a control".+ Experiment 3b (three agent runs on fresh briefs, paid) was not run.++ Background:+ Given the engine's stage is engine/page/stage (stage.show, play, seek, props, pointer, status), driven from a+ page by `call` (@raea/ui/wire), and a headless raea window answers MCP on its own port (never 7477)+ And a render for a pixel check has RAEA_SIGN=0, RAEA_MARK=0, RAEA_AUDIO_MUTE=1 and RAEA_READBACK=rgba+ And every scenario below is a task (docs/agents.md "Tasks: rask"); a status line under a rule says what is built++ Rule: RT0. The live frame is the render's frame+ # Bench (file | job)+ # bench/realtime/stage.sh | rows of stage.tsv: show, pause, seek N, props, a capture after each draw, SSIM+ # bench/realtime/stage.mjs | the MCP driver: stage calls through the page's rt.call action, captures+ # bench/realtime/stage/page.tsx | the window's page: one <img data-raea-stage>, the rt.call action+ # bench/render-play/rows.tsv | the cases' render = play rows; RAEA_RP_ROWS for private copies+ # Status: measured (the table above). Not built: props drawn on a paused frame without a seek, the render's seed+ # and epoch on the stage, the paint look's wind and the trees' motion on the frame's clock in play.++ Scenario: RT0a. 2D and raster on the stage equal the render+ Given a 2D composition and a raster-lit 3D one, each with a control in its defaultProps+ When it is shown on the stage, paused on frame N, and the control changed with stage.props+ Then the next draw equals `raea render --frame N` of a copy with the new value, at SSIM 1.000000+ And it does without a seek after the props (today one is needed: props alone leave the old frame up)+ And HTML over 3D does at >= 0.9994++ Scenario: RT0b. The stage takes the render's seed and start+ Given a composition that reads Math.random and Date+ When the stage shows it+ Then its frames equal the render's at 1.000000 (today 0.998346 on the render's seed, 0.928677 on its own)++ Scenario: RT0c. A film's play equals its render+ Given a raster film whose look moves on its own (wind in the grass, swaying trees)+ Then a play of it equals its render at every frame compared, at 1.000000 (today 0.945 for the goose film)+ And until it does, a live frame is labelled "Preview"++ Scenario: RT0d. A ray-traced frame on the stage+ Given a Solari scene shown on the stage and seeked to frame N+ Then within 30 draws it is within 0.995 of the film's own frame N, or the preview draws without Solari+ And today it isn't: 0.9934 at 32 draws, 0.9942 at 64, against a floor of 0.9968 between two renders++ Scenario: RT0e. A still of a ray-traced film is not its frame+ Given a Solari film+ Then `raea render --frame N` is not the film's frame N (0.905), since Solari's history is the frames before it+ And a ray-traced stage is compared against `render --at 0..N`, never a still++ Rule: RT1. A window render costs the window+ # Bench (file | job)+ # bench/realtime/window.sh | rows of window.tsv: a copy with edit={{ segments, scale }}, rendered as a draft+ # bench/realtime/cases/films.tsx | film-60 and film-180: RR0's six shots round, 1920x1080 at 30 fps+ # Status: measured (the table above). Not built: the warm worker, one start for a draft that meets 3D, unsigned+ # local drafts.++ Scenario: RT1a. The same window of a longer film costs the same+ Given the 5 s window [900, 1050) of a 60 s and of a 180 s 3D film, at scale 0.5+ When each is rendered as host/draft.ts renders it (`raea render COPY -o OUT.mp4 --quality draft`), cold and warm+ Then the 180 s film's window costs no more than 1.5 times the 60 s film's (today a median 1.14)+ And a warm render reaches its first frame within 2 s (today 2.05-3.71 s)++ Scenario: RT1b. A draft starts once+ Given a draft of a window that shows 3D+ Then its render starts its engine once, with its 3D (today the first frame meets 3D and the render starts again)++ Scenario: RT1c. A draft that stays on the machine is unsigned; one that leaves is signed+ Given a draft rendered for the stage+ Then it carries no Content Credentials and makes no call to the signer+ And anything exported, posted or sent for review from it is signed, and a test holds that++ Rule: RT2. What notes ask for+ # Status: measured (the table above); the notes are read only, classified by hand, and not kept in this repo.++ Scenario: RT2a. Notes on composition films, by kind+ Given the last 30 timestamped notes on items whose film is a composition's render+ Then each is value-only (a property the live list holds, or a value on the 2D page) or structural+ And today 8 are value-only (27%), 20 structural and 2 about sound; background reopen and "make this a+ control" are in P1++ Rule: RT3. Playback of pre-rendered video+ # Status: not measured. The founder, 11-16: timeline playback, even of plain pre-rendered videos, is choppy and+ # repeats itself. Measure it first (frames shown against frames due, frames repeated) on a plain .mp4 in the+ # timeline, then fix it.++ Scenario: RT3a. A pre-rendered video plays smoothly and once+ Given a plain .mp4 on the timeline+ When it plays+ Then every frame is shown once, in order, at the film's rate, with none repeated or skipped by a stall