Skip to content

perf: draw each frame of a looping html5 page once - #269

Merged
dazzatronus merged 1 commit into
mainfrom
derk/html5-bake-repeated-frames
Oct 28, 2026
Merged

dazzatronus merged 1 commit into
mainfrom
derk/html5-bake-repeated-frames

Conversation

@dazzatronus

Copy link
Copy Markdown
Contributor

A bake reused a frame only when it matched the one just before it, so a looping animation rasterised every frame it held. A 48 s clip with a 0.5 s CSS grain loop has 15 distinct frames, and it drew all 1,442.

The bake now remembers its last 300 frames by their body markup and reuses any frame that repeats one of them. The page's styles carry the inlined fonts and images, often hundreds of KB, so they're compared separately, and a change to them clears what's remembered. Keying on the body means memory holds markup, not whole SVGs.

Measured on an edit with 15 html5 clips (4,515 frames at 30 fps) in headless desktop Chrome with the GPU. The time from opening the edit until playback is ready went from 117 s to 90 s, and to 72.5 s together with #268.

Verify: npx jest tests/html5-player.test.ts -t "looping page|differ only in their styles". Then bake a clip with animation: x .5s steps(4) infinite and count toBlob calls.

Risk: low. A loop longer than 300 frames (10 s at 30 fps) still draws every frame, as it does today.

@dazzatronus
dazzatronus merged commit 63e4ee7 into main Oct 28, 2026
1 check passed
@dazzatronus
dazzatronus deleted the derk/html5-bake-repeated-frames branch October 28, 2026 03:59
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
## [2.29.5](v2.29.4...v2.29.5) (2026-10-28)

### Performance Improvements

* draw each frame of a looping html5 page once ([#269](#269)) ([63e4ee7](63e4ee7))
* inline html5 images at the size a scaled bake draws them ([#268](#268)) ([6555fd7](6555fd7))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.29.5 🎉

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