Skip to content

fix: keep baking html5 clips while their tab is in the background - #281

Merged
dazzatronus merged 1 commit into
mainfrom
derk/html5-hidden-tab-bake
Oct 30, 2026
Merged

dazzatronus merged 1 commit into
mainfrom
derk/html5-hidden-tab-bake

Conversation

@dazzatronus

Copy link
Copy Markdown
Contributor

An html5 clip's bake all but stops in a background tab. On a hidden page, browsers stop animation frames and hold timers back for a second or more. The bake yields between frames on requestAnimationFrame, with a timer as the fallback, and starts each queued bake on setTimeout(0). On an emulated hidden page in Chrome (requestAnimationFrame never fires, timers held 1 s), a 374-frame bake took 173.5 s. With this change it takes 4.6 s.

nextTask() resolves on a timer while the page is visible, and on a MessageChannel message while it's hidden, because messages aren't held back. nextFrame() and the bake queue use it on hidden pages. Visible pages behave as before.

Once a message answers at once, a bake polling for room in the shared in-flight window would spin a hidden page. So it now waits for any bake's frame to land, on any page.

Verify: npm run verify:ci. Then open an edit with an html5 clip, switch to another tab while it prepares, and come back after a few seconds: preparing has finished.

Risk: a background tab now bakes at full speed, using the CPU and memory a visible one would.

Independent of #279 and #280: it merges cleanly with them, and passes with them.

@dazzatronus
dazzatronus merged commit e1fa158 into main Oct 30, 2026
1 check passed
@dazzatronus
dazzatronus deleted the derk/html5-hidden-tab-bake branch October 30, 2026 22:29
github-actions Bot pushed a commit that referenced this pull request Oct 30, 2026
## [2.30.1](v2.30.0...v2.30.1) (2026-10-30)

### Bug Fixes

* draw clip filters in the preview as the render applies them ([#265](#265)) ([ac02f9b](ac02f9b))
* draw html5 frames on a software canvas so Firefox keeps their gradients ([#280](#280)) ([d508db8](d508db8))
* **export:** draw export frames into one stencil target so Firefox keeps masked content ([#278](#278)) ([f431c6b](f431c6b))
* **export:** tag browser exports as limited range so Safari's whites stay white ([#277](#277)) ([c6150eb](c6150eb))
* keep a frame's embedded images when Safari draws an html5 clip ([#279](#279)) ([5154007](5154007))
* keep baking html5 clips while their tab is in the background ([#281](#281)) ([e1fa158](e1fa158))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.30.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant