Repository navigation
perf: draw each frame of a looping html5 page once - #269
Merged
Merged
Conversation
|
🎉 This PR is included in version 2.29.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withanimation: x .5s steps(4) infiniteand counttoBlobcalls.Risk: low. A loop longer than 300 frames (10 s at 30 fps) still draws every frame, as it does today.