Skip to content

fix(producer): shader transitions blend in Node when the page cannot composite them - #7840

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/engine-shader-blend-follows-page
Nov 15, 2026
Merged

miguel-heygen merged 2 commits into
mainfrom
fix/engine-shader-blend-follows-page

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

What

A render with shader transitions uses page-side compositing only when the composition's own @hyperframes/shader-transitions build actually installs its compositor in this browser. When the build declines, the render blends the transitions on the Node-side layered path instead of capturing the bare opacity flip.

Why

On Chrome 157 every shader transition renders as a plain overlap of the two scenes. Chrome 157 replaced <canvas layoutsubtree> with content="drawable". #7626 taught the engine's fast capture the new form, but @hyperframes/shader-transitions still probes only layoutSubtree, so its page-side compositor declines to install:

[HyperShader] page-side compositing requested but drawElementImage/WebGL is not available; falling back to opacity-flip mode (Node-side layered pipeline will handle the blend).

The producer had already chosen page-side compositing before the page loaded, and so bypassed the Node-side blend:

[Render] Page-side compositing enabled, bypassing Node-side layered shader-blend path.

Neither side drew the shader. Compositions load a pinned shader-transitions build, so teaching the package the new form would not help projects that already exist. The producer has to follow what the page did.

Related work

Refs #7626 (fast capture on Chrome 157+).

How

  • pageInstallsShaderCompositor (renderOrchestrator.ts) loads the page with the page-side stub and checks for the canvas every published shader-transitions build adds once its compositor installs, #__hf-page-side-compositor. That id has been unchanged since the compositor shipped.
  • If the canvas is missing, the render takes the layered route it would take with page-side compositing off. The page is already in the opacity-flip mode that route expects.
  • If the check itself fails to load the page, the render keeps page-side compositing, and the capture stage owns retrying or failing. This is the same rule the fast-capture gate check uses.
  • Cost: one extra page load, only for renders with shader transitions. On the fixture below, capture started 0.4 s later.

Test plan

New regression fixture page-side-shader-compositor-unavailable: a copy of page-side-shader-compositor-render-compat whose page deletes HTMLCanvasElement.prototype.layoutSubtree before the shader-transitions build loads. That reproduces Chrome 157's condition on CI's Chrome 152. Its baseline was generated with --update in Dockerfile.test. It uses the repo's usual minPsnr of 30: the layered shader blend differs a little between machines (CI's runner bottomed out at 39.4 dB in the transition frames), while the bug scores about 11 dB.

Lowest-scoring checkpoints, regression harness, lowest PSNR against the fixture's baseline:

Run main this PR
page-side-shader-compositor-unavailable, Chrome 152 10.97 dB, 46 of 100 checkpoints under 40 dB (bare opacity flip) identical to its baseline in Dockerfile.test (layered route)
page-side-shader-compositor-render-compat, Chrome 152 37.69 dB, page-side 37.69 dB, page-side (unchanged)
page-side-shader-compositor-render-compat, Chrome 157 9.99 dB (bare opacity flip) layered route, shader visible in the transition frames

page-side-shader-compositor-render-compat is in excluded in shard-schedule.json and does not match its baseline on this machine on main either (37.69 dB, both natively and in Dockerfile.test), so its column compares main to this PR, not to a pass. On Chrome 157 its page-side baseline and the layered render draw the transition at different scales, so the PSNR stays low even though the shader is back. I checked those frames by eye. The new fixture goes into timings, so CI runs it.

fails without the fix: page-side-shader-compositor-unavailable (regression harness) fails on main against its baseline: 44 of 100 checkpoints under the 30 dB threshold, lowest 10.97 dB, because the bare opacity flip is captured. "answers from the canvas every published shader-transitions build adds once it composites" in packages/producer/src/services/renderOrchestrator.test.ts fails when the check always answers "installed".

  • Unit tests added: pageInstallsShaderCompositor, 2 tests, 3 runs in a row; the whole renderOrchestrator.test.ts passes (304).
  • bun run typecheck in packages/producer, oxlint and oxfmt --check on the changed files.
  • Manual: renders of page-side-shader-compositor-render-compat on Chrome 152 and Chrome 157, before and after.

Not exercised:

  • GIF output. GIF has no layered route, so a GIF whose shader-transitions build cannot composite still gets the opacity flip. It did before this change too.
  • Chunked (distributed) renders. They already set usePageSideCompositing: false.
  • A shader-transitions build that knows content="drawable". None is published yet; with one, the check simply answers "installed".

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 0539c8781b8ee28414dfb485676be2b6a6fbcf0b.

No introduced blocker found. pageInstallsShaderCompositor observes installation rather than sniffing a browser version, closes its probe in finally, and reuses the existing layered path when the compositor canvas is absent.

Validation:

  • Full build and all 304 renderOrchestrator.test.ts tests pass. Forcing the probe to always report installed fails the new branch test.
  • Native Chrome 152.0.7977.42, regression harness: the unavailable-compositor fixture matches its golden at all 100 checkpoints. Reverting the orchestrator change produces 46 failed checkpoints, minimum 10.97 dB. I inspected the golden at 1.15 seconds: it visibly contains the glitch transition.
  • The working-compositor fixture produces byte-identical output.mp4 files on base and head, retaining page-side capture without Node blending. Its golden mismatch is unchanged on both trees: 41 checkpoints, minimum 37.69 dB.

Pre-existing limitations: this is not fallback on every failure. The catch at renderOrchestrator.ts:4712 retains page-side mode after a probe error; canvas presence does not establish that every shader program initialized; GIF still has no Node layered fallback. The patch improves the missing-canvas case without worsening those cases.

Not tested on dev: local native renders and regression/mutation tests instead. I did not run Chrome 156.0.8078.80 or 157, or a newer shader-transitions build.

Need: yes · Size: ok · Reuse: existing layered compositor and capture plan · Simpler: already minimal · Structure: fine (checked installer and capture routing; no split)
Risk: medium — selects the shader render route.

Verdict: APPROVE
Reasoning: The missing-compositor regression is reproduced and fixed, while the working-compositor control stays byte-identical on the tested browser.

— Rames

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 108 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Re-reviewed at 4c13ff07696857543eba17444ee01804d08868c1. The only change since the last approval (0539c878) is minPsnr going from 45 to 30 in this fixture's meta.json. No code or golden changed. 30 is what 64 of the repo's fixtures use.

30 dB still catches the regression it was added for. This is a 2 s clip with the glitch transition at 0.75 s to 1.6 s. The harness checks 100 evenly spaced checkpoints against maxFrameFailures: 0, so about 40 of them land inside the transition. To bound what a render without the transition would score, I compared each frame of the committed golden against a pure scene A frame and a pure scene B frame. A flip render shows one or the other. Frames 24 through 47 (0.77 s to 1.53 s) are below 30 dB against both: the best of the two tops out at 26.8 dB, and most sit at 9.5 to 14 dB. Wherever the flip lands, that is about 24 failing frames where zero are allowed. Distributed modes floor at 10 dB but take the max with the fixture's 30, so they are unaffected.

The fixture's shard (regression-shards shard-3) passes at this head.

— Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit fb1a383 Nov 15, 2026
137 of 138 checks passed
@miguel-heygen
miguel-heygen deleted the fix/engine-shader-blend-follows-page branch November 15, 2026 14:32
wangzheuser pushed a commit to wangzheuser/hyperframes that referenced this pull request Nov 15, 2026
* chore: release v0.9.53

* chore: release v0.9.53 notes include heygen-com#7836 and heygen-com#7839

* chore: release v0.9.53 notes include heygen-com#7840 and heygen-com#7843
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.

2 participants