Skip to content

Fork patch: Volume probe skips media no setter writes - #15

Draft
ocboogie wants to merge 1 commit into
mainfrom
patch/volume-probe-setter-scan
Draft

ocboogie wants to merge 1 commit into
mainfrom
patch/volume-probe-setter-scan

Conversation

@ocboogie

Copy link
Copy Markdown

Arcade fork patch. Do not merge.

This draft shows patch/volume-probe-setter-scan against main, the upstream mirror, so the patch has one page for its diff, its revisions and its reason. Arcade's /hyperframes-update rebases the branch onto main and cherry-picks it onto arcade; this PR is not part of that flow.

Why

A scene that draws a canvas from scene time through a setter (const clock = { get t(){…}, set t(v){ drawAt(v) } }, tweened by the timeline) freezes the preview for seconds while it mounts.

The preview's volume probe samples a media element's window at 60 whole-timeline seeks per second unless it can rule out volume automation. Since heygen-com#4595, any tween whose non-DOM target has a setter forces that probe for every media element, because a gain proxy writes el.volume that way. A redraw clock has the same shape, so each probe sample is a full canvas redraw. Measured on a three-scene, 30 s film with 19 audio clips: one synchronous task of about 15 s during mount, so the page cannot answer anything until it ends. Render is unaffected (it does not live-probe).

The patch keeps the gain-proxy case and drops the clock case:

  • volumeMoversOf records the setter tweens instead of a single anySetter flag.
  • The first element that needs it seeks the timeline once to the middle of each setter tween, with every <audio>/<video> in the document watched for volume writes. Only elements a setter wrote are sampled. The result is shared by the pass, like the movers index.
  • If a tween cannot be placed on the probed timeline, or an element's volume cannot be watched, it falls back to sampling every element, as before.
  • Limit: a proxy whose setter writes volume only on some calls (for example only after a threshold) and skips the midpoint call would now be missed.

Verified

  • Unit tests: a 25 s redraw clock costs ≤2 setter calls (1,501 before). A gain proxy nested in a time-scaled, offset child timeline is still sampled, and an element beside it that it does not write is skipped. The existing proxy and class-setter tests still pass.
  • Same film in a sandboxed srcdoc iframe, headless Chromium, with the arcade build ± this patch. Without it: one 15.1 s long task, ready at 17.0 s. With it: longest task 196 ms, ready at 1.9–2.2 s. The film has no volume tweens, so both builds play the same audio.

Upstream

Still on upstream main (mediaVolumeEnvelope.ts is unchanged since heygen-com#5674). This looks like a stock-project bug. A public repro and an upstream issue have not been made yet.

Related fork patch: patch/volume-probe-hidden-clips (for heygen-com#7193) also edits probeAndCacheElementVolume, wrapping the sweep. The two patches' changes to mediaVolumeEnvelope.ts merge without conflict.

Drop when

Upstream stops the setter fallback from sampling media that no setter writes.

Arcade

Listed in scripts/arcade/patches.json on patch/arcade-tooling. The next /hyperframes-update publish carries it to the CDN runtime.

@valeriangalliat
valeriangalliat force-pushed the patch/volume-probe-setter-scan branch from 64d43d5 to e3f030b Compare November 10, 2026 23:53
@Pentiado
Pentiado force-pushed the patch/volume-probe-setter-scan branch 2 times, most recently from b54ec67 to 77dfc93 Compare November 16, 2026 20:34
…review sample every clip

A tween on a non-DOM object whose tweened property is a setter made the
volume probe sample every media element at 60 seeks per second of clip,
because a gain proxy writes volume that way. The same shape is a clock
whose setter redraws a canvas from scene time, so mounting such a scene
redrew it once per sample: about 1,500 redraws for a 25 s clip, all in
one task.

The probe now seeks once into the middle of each setter tween with every
media element's volume watched, and samples only the elements a setter
wrote. A gain proxy is still sampled as before; a clock costs one redraw.
A tween it cannot place on the timeline, or an element it cannot watch,
falls back to sampling as before.
@valeriangalliat
valeriangalliat force-pushed the patch/volume-probe-setter-scan branch from 77dfc93 to f8df83c Compare November 25, 2026 00:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant