Skip to content

armgit / raea

Public Imported from GitHub
0

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.

SG17: a CSS animation in a frame rendered alone is where the render has it; L2 holds the frame-order benches

shinyobjectz6d6e81d7f4ec
diff --git a/bench/l2-checks.txt b/bench/l2-checks.txt
new file mode 100644
index 00000000..840de482
--- /dev/null
+++ b/bench/l2-checks.txt
@@ -0,0 +1,11 @@
+# The bench checks L2 runs on every release candidate (tools/l2.sh), each with that commit's raea as RAEA_BIN; each
+# must exit 0. They hold what P26 can't: P26 compares with a baseline, and a baseline drawn by a raea with a fault
+# carries the fault. These say what is right.
+#
+# A frame drawn alone or out of order (--at, --frame) agrees with the render of every frame (docs/stage-guards.feature
+# SG17). 0.1.9 drew a CSS animation in a frame alone from the earliest <Sequence>'s start, or from the frame itself.
+bench/at-0/check.sh
+bench/at-time/check.sh
+bench/at-3d/check.sh
+bench/compute-frames/check.sh
+sdk/react/bench/css/check.sh
diff --git a/docs/stage-guards.feature b/docs/stage-guards.feature
index eba9620b..ad3f022a 100644
--- a/docs/stage-guards.feature
+++ b/docs/stage-guards.feature
@@ -682,3 +682,24 @@ Feature: Stage guards: a 3D render an agent can't break
# the sun's strength follows, kept-light), and says to render a film whole. The skill carries both on its main
# (raea-skills #116, 74ab897); raea's pin takes it with the next pin after the story branch's (ST8a pins 4a77a0b,
# not yet landed: pinning past it here would ship that branch's skill pages before its code).
+
+ Rule: SG17. A frame alone is the render's frame, on a page too
+ @done
+ Scenario: SG17. A CSS animation in a frame rendered alone is where the render has it
+ Given a page composition with CSS animations: one outside any <Sequence>, one inside <Sequence from={10}>
+ (sdk/react/bench/css/anim.tsx)
+ When frame 15 and frame 25 are rendered alone (`render --frame N`) and in a render of every frame
+ Then each animation is at the same place in both: from the composition's start outside a Sequence, from the
+ Sequence's start inside one
+ And L2 runs it on every release candidate with the other frame-order benches (bench/l2-checks.txt: at-0, at-time,
+ at-3d, compute-frames, css), each held to what is right, since P26's baseline carries a fault its raea had
+ # Status 11-22: 0.1.9 drew anim.tsx's A at x 100, not 300, at frame 15 alone: a frame alone mounts every element in
+ # one pass, and the page resolved them all at the earliest <Sequence> start (B's, frame 10), so A began there. On
+ # a page with no <Sequence>, every animation began on the frame itself. engine/page motion.rs now resolves at the
+ # earliest start, with an element outside any Sequence starting at 0, and moves each later element's animations
+ # to its own start (blitz-dom delay_animations). P26 was blind to it: it renders `--at` from frame 0, where every
+ # element mounts on its own frame, and its baseline is 0.1.9's. SG9 still samples only 3D renders: a CSS
+ # transition begun by a style change depends on the frames before it by design, so a page's sample would flag
+ # every one; the engine's side is held here instead. Measured on the fix: css/check.sh's animations PASS (A at
+ # 300 and 500 alone, B at 100 and 300); a page with no <Sequence>, frame 15 alone: x 300 (0.1.9: x 0); the five
+ # L2 bench checks 5/5.
diff --git a/engine/page/src/motion.rs b/engine/page/src/motion.rs
index 71e67152..681103e7 100644
--- a/engine/page/src/motion.rs
+++ b/engine/page/src/motion.rs
@@ -237,7 +237,7 @@ impl BlitzPage {
/// The page made to match `want` (parents before children) with each parent's children in `order`'s order.
pub fn sync(&mut self, want: &[Want], order: &HashMap<u64, Vec<u64>>) {
- let start = self.mount_start(want);
+ let starts = self.mount_starts(want);
let (ops, gone) = self.tree.diff(want, order);
if ops.is_empty() {
return;
@@ -254,18 +254,28 @@ impl BlitzPage {
let mut docs = self.app.world_mut().non_send_mut::<Docs>();
let doc = docs.0.get_mut(&self.page).expect("the page's document");
ops::apply(doc, &mut self.nodes, ops);
- // a render that skips frames (`--at`) meets an element after the frame its <Sequence> started on; its CSS
- // animations run from that start, as in a render of every frame (and raea-runtime-js's page, anim.rs clip_start): the
- // document is resolved there first, between the last frame drawn and this one, so time still only goes forward
- if let Some(at) = start {
+ // a render that skips frames (`--at`, a frame alone) meets elements after they began: at the composition's start,
+ // or their <Sequence>'s. Their CSS animations run from there, as in a render of every frame: the document is
+ // resolved at the earliest (between the last frame drawn and this one, so time still only goes forward), and each
+ // element that began later has its animations begun that much later. Resolving every element at the earliest
+ // <Sequence> start put css/anim.tsx's A, in none, 10 frames behind; with no <Sequence> at all, every animation
+ // began on the frame itself (11-22).
+ if let Some(at) = starts.iter().map(|s| s.1).min_by(f64::total_cmp) {
doc.resolve(at);
+ for &(id, t) in starts.iter().filter(|s| s.1 > at) {
+ if let Some(n) = ops::node(&self.nodes, id) {
+ doc.delay_animations(n, t - at);
+ }
+ }
}
}
- /// The earliest <Sequence> start (data-raea-start, frames), in seconds, of the elements `want` adds, when it lies
- /// after the last frame drawn and before this one.
- fn mount_start(&self, want: &[Want]) -> Option<f64> {
- let (now, before, fps) = self.clock?;
+ /// Each element `want` adds and when it began, in seconds: its <Sequence>'s start (data-raea-start, frames), else
+ /// the composition's (0), when that lies after the last frame drawn and before this one.
+ fn mount_starts(&self, want: &[Want]) -> Vec<(u64, f64)> {
+ let Some((now, before, fps)) = self.clock else {
+ return vec![];
+ };
let by: HashMap<u64, &Want> = want.iter().map(|w| (w.id, w)).collect();
let start_of = |mut id: u64| {
while let Some(w) = by.get(&id) {
@@ -278,10 +288,9 @@ impl BlitzPage {
};
want.iter()
.filter(|w| ops::node(&self.nodes, w.id).is_none())
- .filter_map(|w| start_of(w.id))
- .map(|f| f / fps)
- .filter(|&t| t > before && t < now)
- .min_by(f64::total_cmp)
+ .map(|w| (w.id, start_of(w.id).unwrap_or(0.0) / fps))
+ .filter(|&(_, t)| t > before && t < now)
+ .collect()
}
fn loading(&mut self) -> bool {
diff --git a/sdk/react/bench/css/check.sh b/sdk/react/bench/css/check.sh
index 04b0fe8c..0d10be2c 100755
--- a/sdk/react/bench/css/check.sh
+++ b/sdk/react/bench/css/check.sh
@@ -1,13 +1,13 @@
#!/bin/sh
# A composition's CSS imports and CSS modules reach its page (docs/vite-in-raea.md A2): edit.tsx bundled in process
# (RAEA_BUNDLER=rolldown), its first frame rendered, five pixels checked against what Chrome paints for the same CSS.
-# sdk/react/bench/css/check.sh [RAEA] (default: the repo's target/release/raea)
+# sdk/react/bench/css/check.sh [RAEA] (default: RAEA_BIN, else the repo's target/release/raea)
# Build first: lane build -- cargo build --release -p raea-cli.
set -e
ROOT=$(cd "$(dirname "$0")/../../../.." && pwd)
case ${1:-} in /*|"") ;; *) set -- "$PWD/$1" ;; esac
cd "$(dirname "$0")/../.."
-BIN=${1:-$ROOT/target/release/raea}
+BIN=${1:-${RAEA_BIN:-$ROOT/target/release/raea}}
OUT=${TMPDIR:-/tmp}/raea-css-check
mkdir -p "$OUT"
RAEA_BUNDLER=rolldown RAEA_BUNDLE_CACHE=0 RAEA_AUDIO_MUTE=1 RAEA_READBACK=rgba "$BIN" render bench/css/edit.tsx -o "$OUT/frame.png" --frame 0 > "$OUT/render.log" 2>&1 || { echo "css: FAIL the render failed (see $OUT/render.log)"; exit 1; }
diff --git a/tools/l2.sh b/tools/l2.sh
index 972478aa..865a0bdc 100755
--- a/tools/l2.sh
+++ b/tools/l2.sh
@@ -15,8 +15,8 @@
# made once. A link is never made through a linked folder, so nothing is written into ~/raea.
# - Before building, it sweeps ~/raea's stale debug caches if disk is short, and refuses under 8 GB.
#
-# Output: one line per step ("L2 <step>: ..."), then "L2 <sha>: P26 a/b, ui-parity c/d, conformance e/f" and
-# $OUT/summary.json. Run it under antsy with a stall of 20 minutes or more (a heavy composition prints after
+# Output: one line per step ("L2 <step>: ..."), then "L2 <sha>: P26 a/b, ui-parity c/d, conformance e/f, ..., bench
+# checks g/h" (bench/l2-checks.txt) and $OUT/summary.json. Run it under antsy with a stall of 20 minutes or more (a heavy composition prints after
# rendering all its frames).
set -uo pipefail
ROOT=$HOME/raea
@@ -138,5 +138,16 @@ RAEA_FEED_AGENT=echo "$OUT/bin/conformance" --bin "$OUT/bin/raea-page-host" --su
conf=$(jq -r '"\(.pass)/\(.cases)"' "$OUT/conformance/summary.json" 2>/dev/null || echo "no results")
say "conformance: $conf"
-jq -n --arg sha "$SHA" --arg p26 "$p26" --arg parity "$parity" --arg conf "$conf" --arg bindings "$bindings" '{sha: $sha, p26: $p26, ui_parity: $parity, conformance: $conf, plugin_bindings: $bindings}' > "$OUT/summary.json"
-echo "L2 $SHA: P26 $p26, ui-parity $parity, conformance $conf, plugin bindings $bindings"
+# the bench checks in bench/l2-checks.txt, each run with this commit's raea: they test what is right (a frame drawn alone
+# or out of order agrees with the render), where P26 only compares with its baseline, which can carry the same fault
+ok=0; total=0
+while read -r c; do
+ case $c in '' | '#'*) continue ;; esac
+ total=$((total + 1)); log="$OUT/bench-$(echo "$c" | tr / -).log"
+ if RAEA_BIN="$OUT/bin/raea" bash "$c" </dev/null > "$log" 2>&1; then ok=$((ok + 1)); else say "bench miss: $c ($(tail -1 "$log" | cut -c1-140))"; fi
+done < bench/l2-checks.txt
+benches="$ok/$total"
+say "bench checks: $benches"
+
+jq -n --arg sha "$SHA" --arg p26 "$p26" --arg parity "$parity" --arg conf "$conf" --arg bindings "$bindings" --arg benches "$benches" '{sha: $sha, p26: $p26, ui_parity: $parity, conformance: $conf, plugin_bindings: $bindings, bench_checks: $benches}' > "$OUT/summary.json"
+echo "L2 $SHA: P26 $p26, ui-parity $parity, conformance $conf, plugin bindings $bindings, bench checks $benches"
diff --git a/vendor/blitz-dom/src/resolve.rs b/vendor/blitz-dom/src/resolve.rs
index 6f424492..b947b524 100644
--- a/vendor/blitz-dom/src/resolve.rs
+++ b/vendor/blitz-dom/src/resolve.rs
@@ -35,6 +35,20 @@ use crate::{
};
impl BaseDocument {
+ /// raea: the CSS animations of node `node` (and of its ::before and ::after) begun `by` seconds later than the
+ /// resolve that started them. A page that meets several elements at once, each of which began at its own time (a
+ /// frame rendered alone: the composition's start, a <Sequence>'s), resolves them all at the earliest and moves each
+ /// later one's animations to its own start.
+ pub fn delay_animations(&mut self, node: NodeId, by: f64) {
+ let mut sets = self.animations.sets.write();
+ for (_, set) in sets.iter_mut().filter(|(key, _)| NodeId::from_u64(key.node.id() as u64) == node) {
+ for animation in set.animations.iter_mut() {
+ animation.started_at += by;
+ }
+ set.dirty = true;
+ }
+ }
+
/// Restyle the tree and then relayout it
pub fn resolve(&mut self, current_time_for_animations: f64) {
if TDocument::as_node(&self.root_node())