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

High CPU load #180

Open
nauorama opened this issue Apr 16, 2024 · 8 comments
Open

High CPU load #180

nauorama opened this issue Apr 16, 2024 · 8 comments

Comments

@nauorama
Copy link

Overview

Hello. I was trying to implement animations on a site and noticed that dotlottie-web causes a huge CPU load. You can check it here: https://codepen.io/nauorama/full/LYvJOrZ. This doesn't happen with the @dotlottie/player-component library using the same animations. Can you help, please?

Screenshot 2024-04-16 at 16 50 08
@nauorama nauorama changed the title Hight CPU load High CPU load Apr 16, 2024
@hermet
Copy link
Member

hermet commented Apr 16, 2024

@nauorama Hello, the burden must be shifted from the GPU to the CPU by a software raster engine (ThorVG). Are you experiencing any actual performance issues?

@nauorama
Copy link
Author

@hermet Yes, I'm experiencing performance issues on the site. The animations, other than Lottie, and the SplideJS slider are twitching. Overall, the site does not feel smooth.

@hermet
Copy link
Member

hermet commented Apr 16, 2024

@theashraf Please double-check first if there are areas to improve in dotLottie side, and let us know if it needs thorvg help, thanks.

@theashraf
Copy link
Member

@nauorama
here are some tips that could improve performance a bit

Consider disabling frame interpolation:

new DotLottie({
  canvas: canvas,
  src: src,
  loop: true,
  autoplay: true,
  useFrameInterpolation: false,
});

Adjusting the devicePixelRatio can also help improve performance:

new DotLottie({
  canvas: canvas,
  src: src,
  loop: true,
  autoplay: true,
  useFrameInterpolation: false,
  renderConfig: {
    devicePixelRatio: 1 // Lower values improve performance but may reduce animation quality
  }
});

You can experiment with different values for renderConfig devicePixelRatio. By default, it uses window.devicePixelRatio

@nauorama
Copy link
Author

@theashraf I tried useFrameInterpolation and devicePixelRatio setting. The CPU load is a little bit better, but still very high.

Screenshot 2024-04-16 at 18 35 41

@theashraf
Copy link
Member

@nauorama I'm investigating whether there are any additional optimizations we can introduce

@theashraf
Copy link
Member

@nauorama One final optimization we could introduce is offloading the rendering to a web worker. I've created an example to show how you can run dotLottie in a web worker. You might want to consider it. Let me know if you encounter any issues.

https://codepen.io/lottiefiles/pen/KKYxOJd

@nauorama
Copy link
Author

@theashraf thank you, I will try it

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

No branches or pull requests

3 participants