Repository navigation
fix(core): decode WebKit sources by memory budget, not by length - #7232
Conversation
There was a problem hiding this comment.
Approving at b03b74e8. I found no blocker.
Fails without the fix: confirmed. I put init.ts and webAudioTransport.ts back to the parent (d548e356) and kept the new test. "bare audio in WebKit > hands a 650 s source to a decoded buffer, past the old 600 s limit" then fails with expected "releaseRouted" to be called with arguments: [ <audio …> ]. At the head, webAudioTransport.test.ts and init.test.ts pass locally (402/402).
Checked:
- No race in the accounting. In
init.tsthe only caller that checks the budget callsdecodeAudioElementstraight afterfitsDecodeBudget, in the same tick._pendingDecodeBytesis set before anything awaits, so two sources can't both pass on the same headroom. - A source keeps its verdict for all its clips. A source that is cached or decoding short-circuits to
true, so a clip whose duration is still NaN follows its source. - The estimate is sound.
decodeAudioDataresamples to the context rate, so the estimate (seconds × ctx rate × 2 ch × 4 B) is exact for stereo and twice the real size for mono. If it's wrong, it leaves sources on their element, which is the safe side.
Non-blocking nits:
releaseDecodedExceptdrops a buffer from_bufferCacheeven while anAudioBufferSourceNodeis still playing it. The budget then counts less than is actually held. It's small and short-lived, but worth knowing on iPhone.- The non-scheduled fallback decode (the
effectiveRate === 1path at the end of the capture callback) still decodes without checking the budget. That is unchanged from before, but its buffers now count against the budget for sources that do check it. - As the description says, 256 MB is untested on a real device.
CI: the red Comments check is infrastructure. oven-sh/setup-bun got an HTTP 504, so typescript was missing for the ratchet script. It is not caused by this change and needs a re-run.
The base branch was changed.
Edit accuracy: accurate 267 (base branch 267), smooth 106 of thoseThe gate passes. Quarantined, measured but not gated (8)
Unstable (1)
|
b03b74e to
69b12fd
Compare
There was a problem hiding this comment.
Re-approving at 69b12fdc after the rebase onto main, now that #7225 has merged. I found no blocker.
- The patch is unchanged. Compared against its merge-base, the diff matches
b03b74e8, which I approved, apart from hunk line offsets ininit.ts. - Fails without the fix, confirmed on
main. Withmain'sinit.tsandwebAudioTransport.ts, "bare audio in WebKit > hands a 650 s source to a decoded buffer, past the old 600 s limit" fails withexpected "releaseRouted" to be called with arguments: [ <audio …> ]. At the head,webAudioTransport.test.tsandinit.test.tspass 402/402. - CI on this head: every workflow has a successful run. The cancelled entries are duplicate runs that concurrency superseded.
My earlier non-blocking nits still apply:
- The budget counts less than is held when a released buffer is still playing.
- The fallback decode path still skips the budget check.
- 256 MB hasn't been tried on a phone.
69b12fd to
33c8aa3
Compare
There was a problem hiding this comment.
Re-approving at 33c8aa3b. This head is a rebase only, onto main after the 0.9.16 release.
- The change is unchanged. Compared against its merge-base, the PR's patch matches
69b12fdc, which I approved, apart from index hashes and hunk offsets. It's still the single commit "fix(core): decode WebKit sources by memory budget, not by length". - The tests still pass on the new base. At this head,
webAudioTransport.test.tsandinit.test.tspass 402/402. I confirmed onmainat the previous head that the named 650 s test fails without the fix. - CI: when I approved,
PR captureswas green and the other workflows were still running on this head.
…view Adopts heygen-com#7250 (SVG stroke drawing is not a dead stretch), heygen-com#7248 (contract check reads a timeline registered in a local script), heygen-com#7252 (comma-list selectors hidden by authored CSS), heygen-com#7238 (snapshot and preview show a clip on the render frame), heygen-com#7237 (stalled cloud upload retries) and heygen-com#7251 (per-scene SVG id namespacing), with prerequisite heygen-com#6829. Defers heygen-com#7246 (needs the delivery limiter from heygen-com#6940) and heygen-com#7232 (needs the WebKit decode-first pipeline), with conditions in the ledger. Watermark advances to b108f85. Co-authored-by: Miguel Ángel <miguel.sierra@heygen.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Follow-up to the merged decode-first change. A WebKit source is now decoded when its decoded audio fits a 256 MB memory budget shared by all sources, in place of a fixed 600 s length. A source over the budget stays on its element, as before.
Why
The length limit was a stand-in for memory. Two 9-minute sources fit it one by one and together held 400 MB, while one 11-minute source was refused with room to spare. The budget counts what is held (decoded buffers) and what is being decoded (stereo float estimate from the duration), and a source already decoded or decoding keeps its verdict for all of its clips.
Measured
Unit level only. Decoded size of a 321 s source is 62 MB mono or 123 MB stereo. The budget is my number, not measured on a phone.
Not covered
Tests
fails without the fix: "bare audio in WebKit > hands a 650 s source to a decoded buffer, past the old 600 s limit". On main it reports
expected "releaseRouted" to be called with arguments: [ <audio> ], the sound never leaves its element. New inwebAudioTransport.test.ts, "decode budget": a ten minute source fits and one hour does not, a source that is decoding counts against the next, an unloaded clip is left to its source.Size
About 75 changed lines in two files plus tests; it replaces the 600 s constant the merged change introduced.