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.

#28 (4): the export cache's key takes every file in the edit's folder, not a list of media extensions, so an edited .svg (or .jpeg, or anything a page loads) makes the next render miss; an <img src="/media/logo.svg"> recoloured came back from the cache in its old colour. Dot-files, the output and exports this cache wrote stay out as before. A false miss costs a render, a false hit a stale video. Test: runtime/bundle/tests/cache_inputs.rs (an edited logo.svg and shot.jpeg each change the key; it failed on the .svg before)

shinyobjectz6998f9e3e6a8
diff --git a/runtime/bundle/src/cache.rs b/runtime/bundle/src/cache.rs
index 1b5fa7c9..e725b87b 100644
--- a/runtime/bundle/src/cache.rs
+++ b/runtime/bundle/src/cache.rs
@@ -2,8 +2,8 @@ use super::*;
/// Where a whole-video export of `tsx` is kept (lightspeed T1): named by everything it's made from. That's the bundle's
/// bytes; this binary; the arguments but -o; every RAEA_ setting that isn't a timing or a trace; and each media file
-/// the edit can read, by path, size and modified time (those under its folder, links followed, and every absolute media
-/// path the bundle names). The output's own extension goes in too, and paths as they really are; where it and a
+/// the edit can read, by path, size and modified time (every file under its folder, links followed, and every absolute
+/// media path the bundle names). The output's own extension goes in too, and paths as they really are; where it and a
/// --manifest go, a generation session's token and ledger, playback's mute, and the app's own RAEA_FEED_ settings don't. With --manifest the manifest is kept beside it and comes back with it. None for anything but
/// an .mp4 or .mov, when
/// RAEA_AUDIO_BOUNCE asks for a side file, with RAEA_FRAME_LOG, or with RAEA_EXPORT_CACHE=0; RAEA_EXPORT_CACHE=DIR moves it from
@@ -69,7 +69,10 @@ pub fn export_cache(tsx: &Path, js: &Path, out: &Path, args: &[String]) -> Optio
if depth < 6 {
walk(&p, depth + 1, out, files);
}
- } else if p.extension().and_then(|x| x.to_str()).is_some_and(|x| MEDIA_EXTS.contains(&x.to_ascii_lowercase().as_str()) || matches!(x, "ttf" | "otf" | "woff" | "woff2" | "glb" | "gltf" | "bin" | "json" | "css")) {
+ } else {
+ // every file, whatever its kind: a page loads what it names (an <img> of an .svg or a .jpeg, a CSS
+ // url(), a fetch), and a list of extensions left an edited logo.svg out, so its old picture came back
+ // from the cache (#28). A false miss costs a render, a false hit a stale video
files.push(p);
}
}
diff --git a/runtime/bundle/tests/cache_inputs.rs b/runtime/bundle/tests/cache_inputs.rs
new file mode 100644
index 00000000..625fbc18
--- /dev/null
+++ b/runtime/bundle/tests/cache_inputs.rs
@@ -0,0 +1,29 @@
+//! #28 (4): the export cache's key changes when any file in the edit's folder changes, whatever its kind: an .svg the
+//! page loads as an <img> was left out of it (only a list of media extensions was), so an edited logo came back from
+//! the cache in its old colour.
+
+use std::path::Path;
+
+fn key(tsx: &Path, js: &Path, out: &Path) -> std::path::PathBuf {
+ raea_runtime_bundle::export_cache(tsx, js, out, &[]).expect("a cache key")
+}
+
+#[test]
+fn an_edited_svg_or_jpeg_beside_the_edit_changes_the_export_key() {
+ let dir = std::env::temp_dir().join(format!("raea-cache-inputs-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ std::fs::create_dir_all(dir.join("media")).unwrap();
+ unsafe { std::env::set_var("RAEA_EXPORT_CACHE", dir.join("exports")) };
+ let (tsx, js, out) = (dir.join("edit.tsx"), dir.join("edit.js"), dir.join("out.mp4"));
+ std::fs::write(&tsx, "export {}").unwrap();
+ std::fs::write(&js, "registerRoot()").unwrap();
+ for (file, a, b) in [("logo.svg", "<svg fill='red'/>", "<svg fill='blue'/>"), ("shot.jpeg", "jpeg one", "jpeg two!")] {
+ let p = dir.join("media").join(file);
+ std::fs::write(&p, a).unwrap();
+ let before = key(&tsx, &js, &out);
+ assert_eq!(key(&tsx, &js, &out), before, "the same inputs give the same key");
+ std::fs::write(&p, b).unwrap();
+ assert_ne!(key(&tsx, &js, &out), before, "{file} changed, so the key does");
+ }
+ let _ = std::fs::remove_dir_all(&dir);
+}