lottie-flutter icon indicating copy to clipboard operation
lottie-flutter copied to clipboard

CPU Utilization

Open jonbhanson opened this issue 3 years ago • 9 comments

The package is great, thanks for your work in implementing it!

Sadly, though, I seem to be experiencing high CPU utilization as a result of using the package.

To reproduce, I used this example Lottie file: https://assets3.lottiefiles.com/packages/lf20_guwqiaxe.json. I dropped it into the default Flutter app and ran it on MacOS, and it consumes 20-25% of the CPU on my M1 Macbook Pro.

jonbhanson avatar Jun 09 '22 20:06 jonbhanson

same problem

letungcntt avatar Jul 14 '22 03:07 letungcntt

same problem + 1

LuoLuoDev avatar Dec 14 '22 11:12 LuoLuoDev

same problem + 1

ZhongHaoHero666 avatar Apr 25 '23 10:04 ZhongHaoHero666

same problem + 1

zhangc20 avatar Jun 02 '23 07:06 zhangc20

If an animation is costly to draw, there is the possibility to draw all the frames in a List<Image> and keep them in memory. After the initial cache warmup, it's almost free to draw each frame. It will consume more memory but it can be an acceptable trade-off.

Here is an example of that technique: https://github.com/xvrh/lottie-flutter/blob/master/example/lib/examples/draw_cache.dart

xvrh avatar Jun 02 '23 11:06 xvrh

Also High CPU usage

zhangc20 avatar Jul 27 '23 12:07 zhangc20

The next version v3.0.0-alpha.1 has an experimental parameter enableRenderCache which is meant to make the rendering very cheap for the CPU in exchange of an increased memory usage. Give it a try and report your experience.

xvrh avatar Nov 21 '23 22:11 xvrh

please help same issue CPU utilization shoots to 100%

jeslinjacob1995 avatar Jan 03 '24 08:01 jeslinjacob1995

@jeslinjacob1995 can you try v3.0.0-alpha.4 with the renderCache parameter and report with more information.

xvrh avatar Jan 03 '24 08:01 xvrh