Skip to content

perf(runtime): give each graded canvas its own WebGL context in WebKit - #8848

Open
robinebers wants to merge 1 commit into
heygen-com:mainfrom
robinebers:pr/webkit-grading-context
Open

robinebers wants to merge 1 commit into
heygen-com:mainfrom
robinebers:pr/webkit-grading-context

Conversation

@robinebers

Copy link
Copy Markdown
Contributor

In Safari, colour-graded video drops frames, because WebKit reads the shared WebGL canvas back on every 2D copy. This gives each graded canvas its own context in WebKit, the way the grading preview renderer already does. Other browsers keep the shared context and are not touched.

Measured in Safari 27.2 on a graded 55 s composition, three plays: 6, 5 and 3 dropped frames before, and 2, 2 and 2 after. With grading off it's 1, 1 and 1. One caveat: we measured this together with our frame-source change (separate pull request), not on a plain <video> on its own.

Destroying the renderer releases its context, and a lost context removes that clip's grade.

Test: with a Safari user agent, two graded clips get two contexts, there are no 2D copies, and both contexts are released on destroy.

The colour grade draws every graded clip in one shared WebGL context and copies
the result into each clip's 2D canvas. WebKit reads the WebGL canvas back on
each such copy, so a graded video in Safari drops frames while it plays.

In WebKit each graded canvas now draws with its own WebGL context, as the
grading preview renderer already does, and nothing is copied. A lost context
removes that clip's grade, so the source shows ungraded; a later refresh grades
it again. Destroying such a renderer releases its context. Other browsers keep
the shared context.
@robinebers robinebers changed the title Safari: give each graded canvas its own WebGL context perf(runtime): give each graded canvas its own WebGL context in WebKit Nov 25, 2026

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