Repository navigation
fix(producer): materialize runtime blob and inline data audio during probe - #8932
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at c3bfa88. No blocker; approving.
Read in full: runtimeAudio.ts, the probeStage.ts change with the surrounding media discovery and preflight code, the three new probeStage.test.ts cases, and runtimeAudio.integration.test.ts. Skimmed runtimeAudio.test.ts (case names and assertions). Review by reading; I did not run the tests. CI was still in progress when I posted (24 green, 34 running, none failed).
What I checked
- A blob URL is read only when it starts with the file server's own origin; anything else is logged and left as it was, so the mix still fails loudly instead of dropping a track.
- Per-clip and total byte caps apply before decode (length check on the base64 text) and after; the cache is filled only after a successful write, so a refused source is never reused.
- The blob read runs while the probe page is open and before the audio volume step; the data URI pass runs for static renders too, ahead of
dropMediaOutsideProjectand the media type preflight, so a written file still goes through both. - Files land in
compiled/__hf_runtime_audio/<hash>.<ext>and the integration test resolves that path through the real asset-root check, FFprobe preflight and the audio stage. - "fails without the fix:" names three tests in
probeStage.test.ts; all three exist at this head and assert the new behavior (probe trigger, blob written once for two clips, data URI written with no probe).
Notes, none blocking
decodePercentWithingoes throughdecodeURIComponentand UTF-8, so a percent-encoded payload with raw binary bytes that are not valid UTF-8 is refused. Base64 is the common form, and the refusal warns and leaves the source, so this is a limit and not a wrong output. A byte-wise percent decode would lift it.- The blob path is tested with a mocked
page.evaluate; the in-pagefetch+FileReadercode itself is not run by any test here. The integration test covers the data URI path only. createObjectURL(anywhere in an inline script now starts a probe on any page with managed media, also when the object URL is for an image or a download. Cost only, no wrong result.- An unknown or missing MIME type gives a
.binfile; whether FFmpeg reads it then depends on content sniffing. Fine as a fallback.
Need: yes, preview and export disagreed · Size: fits, 272 lines of code and the rest tests · Reuse: uses the existing compiled dir and asset roots · Simpler: no · Structure: one new module, two call sites
Risk: low; new work only happens for blob or data audio sources, and every refusal leaves the old behavior.
— Rames
Edit accuracy: accurate 273 (base branch 271), smooth 62 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) Unstable (2)
|
|
5fadc5b raises the |
jrusso1020
left a comment
There was a problem hiding this comment.
Re-reviewed at 5fadc5b (approved before at c3bfa88). No blocker; approving.
One commit since my last review. Comparing the full diff at both heads, the only difference is scripts/package-size-budgets.json: the producer's unpacked budget goes from 3740484 to 3800000 bytes (about 60 KB of room). The packed budget and all code and tests are unchanged, so my earlier review and its four notes stand as written.
Not checked: the measured unpacked size at this head (I did not build the package), so I cannot say how much of the new room the change uses.
Need: yes, the new module pushed past the old budget · Size: one line · Reuse: n/a · Simpler: no · Structure: n/a
Risk: low.
— Rames
jrusso1020
left a comment
There was a problem hiding this comment.
Re-reviewed at f8f9e17 (approved before at 5fadc5b). No blocker; approving.
One commit since my last review. Comparing the full diff at both heads, the only difference is in writeRuntimeAudio in runtimeAudio.ts: the existsSync check followed by writeFileSync becomes a single writeFileSync(target, bytes, { flag: "wx" }), with EEXIST swallowed and any other error rethrown. The unused existsSync import is dropped. Behavior is the same for the normal case (a file with the same content hash is kept, not rewritten) and the gap between check and write is gone. Tests and the size budget line are unchanged; my earlier notes stand.
Same as before and not a blocker: a file left half written by an interrupted earlier run in the same work dir would be kept, since the name already exists.
Need: yes, clears the check-then-write pattern · Size: 5 lines · Reuse: n/a · Simpler: no · Structure: n/a
Risk: low.
— Rames
What changed
Compositions whose scripts synthesize or load audio into browser
blob:URLs (viaURL.createObjectURL) or embed inlinedata:audio URIs play in preview, but failed during render becauseaudioMixeronly reads local files andhttp(s)URLs and tried to resolveblob:/data:strings as paths inside the project folder.packages/producer/src/services/render/stages/runtimeAudio.tsto materialize same-originblob:audio URLs from the live probe page and inlinedata:audio URIs intocompiled/__hf_runtime_audio/<sha256>.<ext>(insidecompiledDir, so both local and distributed renders read and clean them up through existing asset roots).blob:URLs, per-clip (64 MiB) and total (128 MiB) byte caps, strict base64/data-URI validation, and content-hash deduplication. Failed, cross-origin, empty, or oversized sources log a warning and stay unchanged so audio mixing fails closed rather than silently dropping tracks.hasRuntimeMediaChangesinpackages/producer/src/services/render/stages/probeStage.tsto probe pages that both contain media elements and callcreateObjectURL(, even when the element is populated through a helper function whose selector cannot be resolved statically.materializeBlobAudioSources(while the probe page is live) andmaterializeDataAudioSources(for both static and probed renders, ahead ofdropMediaOutsideProjectandpreflightCompositionAssetMediaTypes) inprobeStage.ts.Verification
fails without the fix:packages/producer/src/services/render/stages/probeStage.test.ts:probes when a script calls createObjectURL on a page with media elementsmaterializes same-origin blob audio from the probe page into compiledDir and deduplicates shared blobsmaterializes inline data: audio even when no browser probe runsorigin/mainbefore the fix and pass 3/3 runs with the fix.packages/producer/src/services/render/stages/runtimeAudio.test.ts: unit tests covering same-origin vs cross-originblob:handling, MIME extension mapping, byte limits, revoked blobs, base64 and percent-encodeddata:URIs, deduplication, and invalid input refusal (3/3 runs pass under--preload ./scripts/no-network.mjs).packages/producer/src/services/render/stages/runtimeAudio.integration.test.ts(registered inpackages/producer/scripts/integration-tests.json): end-to-end test proving a real PCM WAVdata:URI materializes intocompiled/__hf_runtime_audio/, passesdropMediaOutsideProjectand FFprobepreflightCompositionAssetMediaTypes, and mixes into a realaudio.m4aviarunAudioStagewith FFmpeg (3/3 runs pass).packages/producer/src/services/assetMediaType.test.ts(31/31) andpackages/producer/src/services/render/stages/audioStage.test.ts(18/18) pass.test:classification,tsc --noEmit,oxlint,oxfmt --check, andfallow health(100 A, 0 dead exports, 0 complexity findings) all pass.