Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to use requestAnimationFrame for render frames in preview #148

Merged
merged 4 commits into from
Mar 2, 2021

Conversation

yuta0801
Copy link
Collaborator

This PR adds option to use requestAnimationFrame for play frames instead of setTimeout.

It was just an idea but it improves FPS greatly, especially effective for BetaText in examples.

@JonnyBurger JonnyBurger marked this pull request as ready for review March 2, 2021 15:20
@JonnyBurger
Copy link
Member

Brilliant! 💡

It indeed seems to be faster. I'm not convinced its because of RAF, but I believe it's because of the useRef technique you used.

2 things:

  • I only add to lastFrames if actually triggering a rerender - don't wanna show 60FPS if composition is defined as only 10fps
  • There was a one-off bug in FPS calculation - I fixed it

Result: BetaText example plays in perfect 30.0 FPS!! 🥳
Before it showed like 27.8FPS and in actuality it was even slower because of the bug. You can see the improvement with your own eyes! Thanks a lot 💙

@JonnyBurger JonnyBurger merged commit 08c9438 into remotion-dev:main Mar 2, 2021
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