Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
feat(bench): price the shadow and the gaussians apart from the plumbing
Etienne Lescot77efa27a83c3
diff --git a/docs/architecture/rendering-architecture.md b/docs/architecture/rendering-architecture.mdindex 0439d54b4..71981f58b 100644--- a/docs/architecture/rendering-architecture.md+++ b/docs/architecture/rendering-architecture.md@@ -412,6 +412,139 @@ Two additional findings the gate did not ask for:2. **The Step-2 fixes are confirmed in-run**: legacy 9.8 → shipping 14.6 fps(+49 %) on a project whose per-frame webcam compositing they never touched.+---++## Annex B — Step 3: the L7 row, and what it decides (measured 2026-07-17)++Same machine, same harness, `--clip=4` (122 frames), 4 runs per arm plus one+discarded warm-up, four arms interleaved. **Spread 2–4 %** — the run is valid.+All arms fenced (Annex A), so the compositor's cost is billed to `fence` and not+to the encoder. Shadow is isolated by *pairs*: an arm's twin sets+`shadowIntensity: 0`, because omitting the effect still renders the project's own.++| arm | camera | shadow | wall | ms/frame |+|---|---|---|---:|---:|+| webcodecs-fence | still | on | 4144 ms | 34.0 |+| webcodecs-fence-noshadow | still | off | 3990 ms | 32.7 |+| webcodecs-fence-zoom | moving | on | 5835 ms | 47.8 |+| webcodecs-fence-zoom-noshadow | moving | off | 4659 ms | 38.2 |++Shadow cache: **0.8 % miss** with a still camera (121 hits / 1 miss), **54.1 %+miss** during the zoom (56 / 66) — byte-identical across all four runs, so the+miss rate is a property of the timeline, not of the machine.++**The arithmetic, per frame:**++| item | cost |+|---|---:|+| shadow, cache HOLDING (still camera) | **1.3 ms** |+| shadow, cache MISSING (moving camera) | **16.7 ms** |+| everything else the zoom adds (motion-blur filter, transform) | ~10.1 ms |+| a still frame, all in | 34.0 ms |+| a moving frame, all in | ~59 ms |++So the Step-2 cache is doing exactly what it was built for — it takes the shadow+to ~0 on still frames — and it cannot help on a moving one, by construction. On a+moving frame the shadow alone costs half again as much as the *entire rest* of the+compositor (16.7 vs 32.7 ms). It is the single largest per-frame item there.++**Two findings the ship order did not anticipate:**++1. **§13's decision rule cannot be answered by fps.** It asks for the share of+ *zoom* frames; the cost tracks the share of **moving** frames — the eased+ in/out, not the plateau. A settled zoom holds the cache (that is why 56 of the+ zoom arm's frames still hit). The expensive case is therefore not "a timeline+ with zooms" but auto-focus, which pans with the cursor and moves *every* frame+ of its region. The product question — "how much of a typical timeline has a+ MOVING camera" — is the user's, not the bench's.+ **Answered, 2026-07-17 (product owner): a moving camera is the norm.** Screen+ presentations carry zooms by nature; the webcam is commonly set to resize+ reactively *during* those zooms; and Full Camera animates the webcam across the+ whole stage. That is §13's "≳ 50 %" branch — **Step 4 is warranted**, subject+ to B.1 below.+2. **Step 4 as specified does not fix this.** §8b lists the compositor's caches as+ "wallpaper 1× · **shadow per-geometry** · masks per-shape · …" — the same+ geometry key, hence the same 54 % miss during motion. The unified WGSL+ compositor only removes this cost if the shadow is *computed* per frame in the+ shader rather than cached — and §13 explicitly forbids the SDF/`smoothstep`+ approximation that would make that cheap, because the cascaded falloff has+ burned this codebase twice. **Unresolved: a shader that reproduces the exact+ 3-pass cascade at 1080p, and its cost.** That, not the fps, is Step 4's real+ gate.++### B.1 — What the 16.7 ms actually is, and therefore what fixes it++A cache miss is two stacked things: the three chained gaussians, and the+full-frame Canvas2D plumbing feeding them (silhouette copy, `source-in` fill,+filtered blit — 2 Mpx each). They have different fixes, so they were priced apart+with a third arm that runs the whole miss path with the filter chain switched off+(`openscreen.shadowNoFilter` — renders no shadow; diagnostic only). Timing the+ops individually would have answered nothing: Canvas2D is as lazy as the GPU, so+a timer around a `drawImage` measures submission and bills the work to whatever+syncs next (§7.4). Hence an arm pair, both fenced.++`fence` totals, 122 frames, 66 of them missing the cache — two independent runs:++| arm | run A | run B |+|---|---:|---:|+| zoom + shadow | 3668 ms | 4086 ms |+| zoom + shadow, no gaussians | 2734 ms | 2964 ms |+| zoom, no shadow at all | 2513 ms | 2730 ms |+| **⇒ gaussians** | **934 ms** | **1122 ms** |+| **⇒ plumbing** | **221 ms** | **234 ms** |++**The gaussian chain is ~81 % of the miss** (~14.2 ms per moving frame, against+~3.3 ms of plumbing). Run B is VOID on its own spread gate (31 %; the machine had+been benching continuously for ten minutes and was drifting) — but it is reported+because the two runs agree on the *ratio* (4.2 : 1 and 4.8 : 1) while disagreeing+on the absolute, which is exactly what interleaved arms under drift should do.+A 4 : 1 ratio does not turn over inside that noise.++**So: touching less of the frame recovers ~3 ms; the fix has to be the filter.**+Which is where §13's prohibition needs a distinction it does not currently make:++> **The ban is on a different falloff, not on a different implementation.** §13+> forbids replacing the shadow with an SDF/`smoothstep` — rightly: that is an+> *approximation of a different shape*, and it has burned this codebase twice.+> But CSS `drop-shadow` is not a black box. It is `feGaussianBlur` on SourceAlpha,+> and the SVG filter spec **defines** that blur, for our radii, as three+> successive box blurs of a specified width. Reimplementing that cascade in a+> shader is the same algorithm on a different device — not an approximation.+> Box blurs are separable and O(1) per pixel; this is the cheap case on a GPU.+>+> That claim is falsifiable and must be falsified before it is built: the spike is+> a GPU pass rendering the same silhouette, pixel-diffed against the Canvas2D+> output. If they do not match, this paragraph is wrong. Skia's real path may not+> follow the spec's letter.++**Consequence for the ship order.** The spike stands alone — it replaces+`cachedShadowLayer`'s filter with a GPU pass and needs no architecture change, so+it pays off inside Electron today *and* is exactly the shadow §8b's compositor+needs. It should be measured before Step 4 is committed to, not during it.++**Bench corrections this measurement forced** (each was silently wrong before):++- The `zoom` effect injected `depth: "medium"`; `ZOOM_DEPTH_SCALES` keys on 1–6,+ so the lookup returned `undefined` and **the zoom never ran**. Every previous+ zoom arm reported a clean number for an effect that did nothing. The injected+ region is now parsed through `zoomRegionSchema` — the pipeline's own contract.+- The session's **first export** pays for shader compilation, decoder setup and+ JIT (9.3 s vs 5.6/6.6/5.8 s for its own repeats) and lands on whichever arm ran+ first: a 60 % same-arm spread that voided two runs by itself. One discarded+ warm-up per arm brings the spread to 2–4 %.+- Effects are now per-arm (`addEffects`), so an effect is A/B'd inside ONE+ interleaved run. `--effects` alone is one value per session, which turns any+ effect comparison into a cross-session one — the mistake this bench exists to+ prevent.++**Reference-project caveat.** `proj_5b3ac6bc`'s first clip declares+`durationSec: 4.03` but holds ~2.03 s of decodable video (its own zooms, authored+at 3163 ms, are past the end and never fire — which is why the still arms sit at+0.8 % miss). The measurement stands on the injected zoom; the stale duration is+its own bug, unrelated to rendering.++---+**Step-0 note (data loss, §13).** The record's reference project `os_parity`(`proj_de6ffaaa…openscreen`) was found corrupted with exactly the §13 signature:a complete, valid save (updatedAt 2026-07-16T18:00:26Z) followed by the tail of adiff --git a/scripts/bench-export.mjs b/scripts/bench-export.mjsindex 28efa53fe..b7495986f 100644--- a/scripts/bench-export.mjs+++ b/scripts/bench-export.mjs@@ -158,6 +158,27 @@ function report(results) {console.log("\n=== export bench ===");console.table(rows);+ // The shadow cache only holds while the geometry is still, so its miss rate is+ // what a moving camera (zoom, auto-focus pan) actually costs — see Step 3.+ const shadowRows = [];+ for (const arm of arms) {+ const runs = results.filter((r) => r.arm === arm && r.ok && r.shadow);+ if (runs.length === 0) continue;+ const hits = median(runs.map((r) => r.shadow.hits));+ const misses = median(runs.map((r) => r.shadow.misses));+ const total = hits + misses;+ shadowRows.push({+ arm,+ hits,+ misses,+ "miss %": total === 0 ? "n/a" : `${((misses / total) * 100).toFixed(1)}%`,+ });+ }+ if (shadowRows.length) {+ console.log("shadow cache (median):");+ console.table(shadowRows);+ }+const stageKeys = [...new Set(results.flatMap((r) => Object.keys(r.stages ?? {})))];const stageRows = stageKeys.map((stage) => {const row = { stage };@@ -190,6 +211,7 @@ async function main() {// Iteration cap: bench only the first N seconds of timeline. Numbers from// capped runs compare per-frame, or against runs with the SAME cap....(args.clip ? { clip: args.clip } : {}),+ ...(args.warmup ? { warmup: args.warmup } : {}),arms: args.arms ?? "webcodecs,native",runs: args.runs ?? "2",fps: args.fps ?? "60",@@ -248,11 +270,14 @@ async function main() {console.log(` ${event.arm} run ${event.run}: ${status}`);} else if (event.event === "fatal") {fatal = event.error;+ } else if (event.event === "warmup") {+ console.log(` (warm-up) ${event.arm}: ${Math.round(event.wallMs)}ms — discarded`);} else if (event.event === "start") {console.log(` project: ${event.project}`);console.log(` effects: ${event.effects}`);if (event.clip) console.log(` clip: first ${event.clip}s only (iteration cap)`);- console.log(` arms: ${event.arms.join(", ")} x${event.runs}\n`);+ console.log(` arms: ${event.arms.join(", ")} x${event.runs}`);+ console.log(` warm-up: ${event.warmup} discarded run(s) per arm\n`);}}};diff --git a/src/bench/runBench.ts b/src/bench/runBench.tsindex 5ff461a1d..0dece59c2 100644--- a/src/bench/runBench.ts+++ b/src/bench/runBench.ts@@ -18,7 +18,7 @@*/import { exportAxcutDocument } from "@/lib/ai-edition/exporter/documentExporter";-import type { AxcutDocument } from "@/lib/ai-edition/schema";+import { type AxcutDocument, zoomRegionSchema } from "@/lib/ai-edition/schema";import type { ExportQuality } from "@/lib/exporter";import { nativeBridgeClient } from "@/native/client";@@ -34,6 +34,18 @@ export interface BenchArm {legacyCompositor?: boolean;/** Gate G0: sync the GPU after compositing, in a `fence` stage of its own. */gpuFence?: boolean;+ /** Diagnostic: shadow path minus the gaussians. Renders no shadow. */+ shadowNoFilter?: boolean;+ /**+ * Effects this arm adds to --effects, so an effect can be A/B'd INSIDE one+ * interleaved run.+ *+ * --effects alone cannot answer "what does this effect cost": it is one value+ * for the whole session, so the comparison becomes two sessions — and this+ * machine drifts further between sessions (up to 62%) than any effect is+ * worth. That is the mistake this bench exists to prevent.+ */+ addEffects?: string[];}export interface BenchRunResult {@@ -49,6 +61,8 @@ export interface BenchRunResult {fps: number;/** Per-stage totals in ms, keyed as StageTimings names it. */stages: Record<string, number>;+ /** Shadow cache hits/misses for the run — see BenchArm.addEffects / Step 3. */+ shadow?: { hits: number; misses: number };}const params = new URLSearchParams(window.location.search);@@ -73,6 +87,12 @@ const BENCH_PARAMS = {// what 820 say, at a quarter of the wait. Wall/fps from a capped run are NOT// comparable with full-length runs — compare per-frame, or same-cap runs.clip: params.get("clip") ? Number(params.get("clip")) : null,+ // Discarded runs before the measured ones. The session's FIRST export pays for+ // shader compilation, decoder setup and JIT, and it lands on whichever arm ran+ // first: measured at 9.3 s against 5.6/6.6/5.8 s for its own repeats — a 60%+ // same-arm spread that voided the run all by itself, while the arm that merely+ // went second looked better. One warm-up costs ~5 s at --clip=4.+ warmup: Number(params.get("warmup") ?? "1"),};/**@@ -94,6 +114,12 @@ const EFFECT_PATCHES: Record<string, Record<string, unknown>> = {blur: { showBlur: true },radius: { borderRadius: 24 },motionBlur: { motionBlurAmount: 1 },+ // Turning an effect OFF is not the same as omitting it: a saved project has+ // its own appearance (this bench's reference carries shadowIntensity 0.52 and+ // motionBlurAmount 0.31), so an arm that "doesn't add shadow" still renders+ // the project's. These patches are what make an arm PAIR isolate one effect.+ noShadow: { shadowIntensity: 0 },+ noMotionBlur: { motionBlurAmount: 0 },};/**@@ -103,18 +129,26 @@ const EFFECT_PATCHES: Record<string, Record<string, unknown>> = {* GEOMETRY every frame, so it is what invalidates any geometry-keyed cache. A* parity test on a project without zoom would happily pass with a broken cache* key, because nothing would ever ask it to invalidate.+ *+ * Parsed through the real schema before it is injected, because this region was+ * born with `depth: "medium"` — a value nothing accepts. `ZOOM_DEPTH_SCALES`+ * keys on 1..6, so the lookup returned undefined and the zoom silently did+ * NOTHING: the arm reported a clean number for an effect that never ran. The+ * schema is the only thing that knows what the pipeline accepts, so ask it.*/function zoomRanges(doc: AxcutDocument): unknown[] {const clips = (doc as { timeline?: { clips?: { timelineEndSec?: number }[] } }).timeline?.clips;const endSec = clips?.[0]?.timelineEndSec ?? 5;return [- {+ zoomRegionSchema.parse({id: "bench-zoom",startMs: 500,endMs: Math.max(1500, Math.round(endSec * 1000) - 500),- depth: "medium",+ // 3 is DEFAULT_ZOOM_DEPTH, and what the reference project's own zoom uses.+ depth: 3,focus: { cx: 0.5, cy: 0.5 },- },+ focusMode: "manual",+ }),];}@@ -234,6 +268,49 @@ const ARMS: Record<string, BenchArm> = {legacyCompositor: true,gpuFence: true,},+ // Step 3 (rendering-architecture.md §13): the missing L7 row. A zoom is the one+ // effect that moves the composited geometry every frame, so it is what the+ // shadow cache cannot hold — pair it with `webcodecs-fence` in ONE interleaved+ // run and the difference is the cost of a moving camera, on one thermal state.+ // Fenced on both sides so the compositor's cost lands in `fence` on both,+ // instead of hiding in the encoder's queue on both.+ "webcodecs-fence-zoom": {+ nativeEncode: false,+ readFrequently: false,+ gpuFence: true,+ addEffects: ["zoom"],+ },+ // The other half of the Step-3 question. A zoom does not only miss the shadow+ // cache — it also puts the camera in motion, which switches the motion-blur+ // filter on. Run these two against the pair above and the arithmetic separates+ // the shadow from everything else the zoom drags in:+ // (zoom − zoom-noshadow) = the shadow with the cache MISSING every frame+ // (still − still-noshadow) = the shadow with the cache HOLDING+ // Without them, "zoom is slower" is true and says nothing about what to fix.+ "webcodecs-fence-noshadow": {+ nativeEncode: false,+ readFrequently: false,+ gpuFence: true,+ addEffects: ["noShadow"],+ },+ "webcodecs-fence-zoom-noshadow": {+ nativeEncode: false,+ readFrequently: false,+ gpuFence: true,+ addEffects: ["zoom", "noShadow"],+ },+ // Splits the 16.7 ms cache miss in two, which is what decides the SHAPE of the+ // fix. Against `webcodecs-fence-zoom` it prices the three gaussians; against+ // `webcodecs-fence-zoom-noshadow` it prices the full-frame plumbing that feeds+ // them. A shader is the answer to the first; touching less of the frame is the+ // answer to the second. Renders no shadow — measurement only, never shipped.+ "webcodecs-fence-zoom-nofilter": {+ nativeEncode: false,+ readFrequently: false,+ gpuFence: true,+ shadowNoFilter: true,+ addEffects: ["zoom"],+ },// These two WRITE FILES, which is what makes them the parity gate: encode the// same timeline with the old and new compositor through the same encoder at// the same bitrate, then diff the results (SSIM). Unit tests never look at a@@ -248,6 +325,7 @@ function applyArm(arm: BenchArm): void {localStorage.setItem("openscreen.compositeOnly", arm.compositeOnly ? "1" : "0");localStorage.setItem("openscreen.legacyCompositor", arm.legacyCompositor ? "1" : "0");localStorage.setItem("openscreen.gpuFence", arm.gpuFence ? "1" : "0");+ localStorage.setItem("openscreen.shadowNoFilter", arm.shadowNoFilter ? "1" : "0");}/**@@ -327,6 +405,8 @@ interface Captured {stages: Record<string, number>;/** The exporter's own loop numbers, which exclude the bench's setup. */loop: { wallMs: number; frames: number; fps: number } | null;+ /** Shadow cache hits/misses — the Step-3 decision input. */+ shadow: { hits: number; misses: number } | null;restore: () => void;}@@ -335,6 +415,7 @@ function captureStages(): Captured {const captured: Captured = {stages: {},loop: null,+ shadow: null,restore: () => {console.warn = original;},@@ -352,6 +433,11 @@ function captureStages(): Captured {fps: Number(head[3]),};}+ // "[export perf] shadow cache: 100 hits, 20 misses (16.7% miss of 120)"+ const shadow = /shadow cache:\s*(\d+)\s+hits,\s*(\d+)\s+misses/.exec(text);+ if (shadow) {+ captured.shadow = { hits: Number(shadow[1]), misses: Number(shadow[2]) };+ }for (const line of text.split("\n")) {// " render 1680.0 3.0% 3.08 n=546"const m = /^\s*([a-zA-Z]+)\s+([\d.]+)\s+[\d.]+%/.exec(line);@@ -398,6 +484,7 @@ async function runOnce(frames: capture.loop.frames,fps: capture.loop.fps,stages: capture.stages,+ shadow: capture.shadow ?? undefined,};} catch (error) {return {@@ -433,23 +520,46 @@ export async function runBench(): Promise<void> {for (const armName of BENCH_PARAMS.arms) {if (!ARMS[armName]) throw new Error(`Unknown arm "${armName}"`);}- // Loaded once and shared by every run: each arm must see byte-identical- // input, and the title fallback can open every project on disk.+ // Loaded once: the title fallback can open every project on disk, and every+ // arm must see the same source document.// Cap BEFORE effects, so the injected zoom fits inside the capped window.- const doc = withEffects(- withClipCap(await resolveDocument(BENCH_PARAMS.project), BENCH_PARAMS.clip),- BENCH_PARAMS.effects,- );+ const base = withClipCap(await resolveDocument(BENCH_PARAMS.project), BENCH_PARAMS.clip);+ // One document per EFFECT SET, not per arm: arms sharing a set share the+ // exact object, so they cannot differ by anything but their own flags.+ const docs = new Map<string, AxcutDocument>();+ const docFor = (arm: BenchArm): AxcutDocument => {+ const effects = [...BENCH_PARAMS.effects, ...(arm.addEffects ?? [])];+ const key = effects.join(",");+ const existing = docs.get(key);+ if (existing) return existing;+ const built = withEffects(base, effects);+ docs.set(key, built);+ return built;+ };emit("start", {arms: BENCH_PARAMS.arms,runs: BENCH_PARAMS.runs,- project: doc.project?.title ?? "(untitled)",+ project: base.project?.title ?? "(untitled)",effects: BENCH_PARAMS.effects.length ? BENCH_PARAMS.effects.join("+") : "(project default)",clip: BENCH_PARAMS.clip,+ warmup: BENCH_PARAMS.warmup,});+ // Warm up EVERY arm, not just the first: each one's first pass is the one+ // that pays. Results are dropped on the floor.+ for (let w = 0; w < BENCH_PARAMS.warmup; w++) {+ for (const armName of BENCH_PARAMS.arms) {+ const arm = ARMS[armName];+ const result = await runOnce(docFor(arm), armName, arm, 0);+ // A warm-up that FAILS is still a broken arm — say so now rather than+ // let the measured pass report the same failure four times.+ if (!result.ok) throw new Error(`warm-up failed for ${armName}: ${result.error}`);+ emit("warmup", { arm: armName, wallMs: result.wallMs, fps: result.fps });+ }+ }for (let run = 1; run <= BENCH_PARAMS.runs; run++) {for (const armName of BENCH_PARAMS.arms) {- const result = await runOnce(doc, armName, ARMS[armName], run);+ const arm = ARMS[armName];+ const result = await runOnce(docFor(arm), armName, arm, run);results.push(result);emit("run", result);}diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.tsindex 2acfb6499..222dc69ac 100644--- a/src/lib/exporter/frameRenderer.ts+++ b/src/lib/exporter/frameRenderer.ts@@ -120,6 +120,32 @@ function legacyCompositorRequested(): boolean {}}+/**+ * Diagnostic: run the shadow's cache-miss path but SKIP the filter chain.+ *+ * A cache miss costs 16.7 ms/frame (Annex B), and that number is two different+ * things stacked: three chained gaussians, and the full-frame Canvas2D plumbing+ * that feeds them (a silhouette copy, a source-in fill, a filtered blit — 2 Mpx+ * each). They do not have the same fix. A shader only helps if the gaussians are+ * the cost; if it is the plumbing, the fix is to stop touching the whole frame.+ *+ * Timing the ops individually would answer nothing — Canvas2D is as lazy as the+ * GPU, so a timer around a drawImage measures submission and bills the work to+ * whatever syncs next (§7.4). Hence a flag and an arm PAIR instead: same path,+ * one filter, one none, both fenced.+ *+ * The output is wrong on purpose (no shadow is drawn). Diagnostic only.+ *+ * localStorage.setItem("openscreen.shadowNoFilter", "1")+ */+function shadowFilterDisabled(): boolean {+ try {+ return localStorage.getItem("openscreen.shadowNoFilter") === "1";+ } catch {+ return false;+ }+}+/*** The recording's drop shadow, as a CSS filter chain.*@@ -211,8 +237,19 @@ export class FrameRenderer {private maskShape: { width: number; height: number; radius: number } | null = null;/** Bench-only: undo the compositor fixes so they can be measured. */private legacyCompositor = legacyCompositorRequested();+ /** Bench-only: price the filter chain apart from the plumbing feeding it. */+ private shadowNoFilter = shadowFilterDisabled();/** Shadow filter output, keyed by the geometry it was computed for. */private shadowCache: { key: string; canvas: HTMLCanvasElement } | null = null;+ /**+ * How often the geometry key held, and how often it paid for the filter chain.+ *+ * The miss rate IS the Step-3 decision input (see rendering-architecture.md+ * §13): the cache captures the shadow's cost on still frames, and a moving+ * camera must miss by design. Only a count says which case a real timeline is.+ */+ private shadowCacheHits = 0;+ private shadowCacheMisses = 0;/** Scratch holding videoCanvas's alpha as an opaque black shape. */private shadowSilhouetteCanvas: HTMLCanvasElement | null = null;/** The wallpaper, blurred once. It is a still image — see blurredBackgroundLayer. */@@ -1223,7 +1260,11 @@ export class FrameRenderer {h: number,): HTMLCanvasElement | null {const key = this.shadowGeometryKey();- if (this.shadowCache?.key === key) return this.shadowCache.canvas;+ if (this.shadowCache?.key === key) {+ this.shadowCacheHits++;+ return this.shadowCache.canvas;+ }+ this.shadowCacheMisses++;if (!this.shadowSilhouetteCanvas) {this.shadowSilhouetteCanvas = document.createElement("canvas");@@ -1249,7 +1290,8 @@ export class FrameRenderer {silCtx.globalCompositeOperation = "source-over";outCtx.globalCompositeOperation = "copy";- outCtx.filter = shadowFilterChain(this.config.shadowIntensity);+ // Diagnostic arm: everything but the gaussians, so the pair prices them.+ if (!this.shadowNoFilter) outCtx.filter = shadowFilterChain(this.config.shadowIntensity);outCtx.drawImage(this.shadowSilhouetteCanvas, 0, 0, w, h);outCtx.filter = "none";outCtx.globalCompositeOperation = "source-over";@@ -1450,6 +1492,11 @@ export class FrameRenderer {return this.compositeCanvas;}+ /** Shadow cache hits/misses for the frames rendered so far — see the fields. */+ shadowCacheStats(): { hits: number; misses: number } {+ return { hits: this.shadowCacheHits, misses: this.shadowCacheMisses };+ }+/*** Bench-only sync point — gate G0, docs/architecture/rendering-architecture.md §7.1.*diff --git a/src/lib/exporter/videoExporter.ts b/src/lib/exporter/videoExporter.tsindex 9abb98ad9..9bed88c0f 100644--- a/src/lib/exporter/videoExporter.ts+++ b/src/lib/exporter/videoExporter.ts@@ -1654,6 +1654,18 @@ export class VideoExporter {timings.formatSummary({ frames: frameIndex, hardwareAcceleration: encoderPreference }),);+ // The shadow cache only pays off on frames whose geometry is still, so its+ // miss rate — not the wall — is what says whether a moving camera leaves the+ // per-frame shadow in place (rendering-architecture.md §13, Step 3).+ const shadowStats = renderer.shadowCacheStats();+ const shadowLookups = shadowStats.hits + shadowStats.misses;+ if (shadowLookups > 0) {+ const missPct = ((shadowStats.misses / shadowLookups) * 100).toFixed(1);+ console.warn(+ `[export perf] shadow cache: ${shadowStats.hits} hits, ${shadowStats.misses} misses (${missPct}% miss of ${shadowLookups})`,+ );+ }+if (compositeOnly) {warnings.push("Composite ceiling diagnostic: rendered only, no file was written.");return { success: true, warnings };