Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

bake cache: key the folder by browser binary as well as version; Chrome for Testing and chrome-headless-shell both report 153.0.8010.12 and rasterise differently

Alex Greenshpun80d12d964b74
diff --git a/skills/anidoodle/engine/tools/adapters/playwright.mjs b/skills/anidoodle/engine/tools/adapters/playwright.mjs
index be46717..10bdcc3 100644
--- a/skills/anidoodle/engine/tools/adapters/playwright.mjs
+++ b/skills/anidoodle/engine/tools/adapters/playwright.mjs
@@ -1,6 +1,7 @@
// PLAYWRIGHT ADAPTER. Thin by design: open the generated page, ask it for frame N, take the
// canvas pixels. Frame accuracy comes from the pull model (frame N is a pure function of N),
// not from anything Playwright does.
+import { createHash } from "node:crypto";
import { pathToFileURL } from "node:url";
import { bakeCacheOn, loadBakes, saveBakes } from "../bake-cache.mjs";
@@ -8,7 +9,10 @@ export const name = "playwright";
// bakeCache (default on): finished plate frames come from and go to .cache/bakes (see bake-cache.mjs)
export const open = async ({ pw, browser: found }, pagePath, { scale = 1, workers = 1, bakeCache } = {}) => {
const browser = await pw.lib.chromium.launch({ executablePath: found.executablePath, args: ["--disable-background-timer-throttling"] });
- const useBakes = bakeCacheOn(bakeCache), bv = browser.version(); let loadedBakes = 0;
+ // the bake folder is keyed by the browser BINARY, not just its version: Chrome for Testing and
+ // chrome-headless-shell report the same version and rasterise differently, so one must never
+ // replay the other's plate frames
+ const useBakes = bakeCacheOn(bakeCache), bv = `${browser.version()}-${createHash("md5").update(found.executablePath ?? "playwright-default").digest("hex").slice(0, 8)}`; let loadedBakes = 0;
const context = await browser.newContext({ viewport: { width: 640, height: 640 }, deviceScaleFactor: 1 });
const pages = [];
for (let i = 0; i < workers; i++) { const page = await context.newPage(); const errors = []; page.on("pageerror", (e) => errors.push(e.message)); await page.goto(pathToFileURL(pagePath).href + "?adapter=playwright"); await page.evaluate(async (s) => { await window.FILM.ready; window.FILM.mount(s); }, scale); if (useBakes) loadedBakes = await loadBakes(page, bv); await page.evaluate(() => window.FILM.warm()); /* warm = build texture tiles once, outside the timed frames */ if (errors.length) throw new Error("page failed: " + errors.join("; ")); pages.push(page); }
diff --git a/skills/anidoodle/engine/tools/bake-cache.mjs b/skills/anidoodle/engine/tools/bake-cache.mjs
index c1fe9da..2489479 100644
--- a/skills/anidoodle/engine/tools/bake-cache.mjs
+++ b/skills/anidoodle/engine/tools/bake-cache.mjs
@@ -1,5 +1,5 @@
// BAKE CACHE, the disk half of Env.bake (the page half is hosts/page.ts). Finished plate frames
-// live in .cache/bakes/<browser version>/<source hash>.<frame>.<w>x<h>.png. The source hash is
+// live in .cache/bakes/<browser version>-<binary hash>/<source hash>.<frame>.<w>x<h>.png. The source hash is
// computed by build-page.mjs over the plate's whole import closure, so an edited plate simply
// misses and is drawn again; a different browser build (which may rasterise differently) gets a
// different folder. Nothing here is ever needed: delete .cache/ and every frame is drawn cold.
diff --git a/skills/anidoodle/references/working-method.md b/skills/anidoodle/references/working-method.md
index 9ab1010..2990a04 100644
--- a/skills/anidoodle/references/working-method.md
+++ b/skills/anidoodle/references/working-method.md
@@ -67,7 +67,7 @@ None of that was drawing. These habits cut it by an order of magnitude:
in one page (one build, one launch, plates baked once); ranges work too, `--frames 0-300:50`
is every 50th frame from 0 to 300. Add `--sheet out/sheet.jpg` for a contact sheet of them at
`--sheet-scale` (default 0.4). `--out out/dir/` or `--out out/x-{frame}.png` names the PNGs.
-- **Plate cache.** Finished plate frames are kept in `engine/.cache/bakes/<browser version>/`,
+- **Plate cache.** Finished plate frames are kept in `engine/.cache/bakes/<browser version>-<binary>/`,
keyed by a hash of the plate's whole import closure, so a wall of 31 live plates stops
re-baking (about 60 s) on every still, and an edited plate simply misses and is drawn again.
It is never needed: delete `.cache/` any time. `--no-bake-cache` (or `ANIDOODLE_BAKE_CACHE=0`)