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 memory consumption causing OOM crash #828

Closed
Jonge opened this issue Mar 27, 2019 · 5 comments
Closed

High memory consumption causing OOM crash #828

Jonge opened this issue Mar 27, 2019 · 5 comments

Comments

@Jonge
Copy link

Jonge commented Mar 27, 2019

First of all, thank you for the library, seems like almost a perfect solution to pretty animations on iOS! 👍

This issue is a:

  • Crashing Bug

Which Version of Lottie are you using?

Lottie 3.0.3

What Platform are you on?

  • iOS

What Language are you in?

  • Swift

Expected Behavior

An animation should not take more than say several dozen MBs of memory.

Actual Behavior

So the problem is that we have a pretty complex animation (many layers, transparency, masks), and the duration is also quite long. The JSON has about 700 kB.

Still, when it's used on the web, it needs only about 100 MB of RAM. However, when starting an animation of the same file used on iOS, it leads to the allocation of about 2 GB of RAM, playing for a while, and then crashing due to insufficient memory.

Even when splitting the animation into 9 parts, a single part still uses about 200 MB of memory, which is quite a lot (since the whole app uses only about 100 MB).

Moreover, I noticed that changing the animation view size doesn't improve the memory consumption much (e.g. when I changed the frame to 10x10 pts, it still used about 150 MB of RAM).

Do you think it would be possible to optimize the performance, or is that impossible because of how Lottie/After Effects work? To me, �it seems that Lottie is trying to render all frames in the beginning, is that true? And if yes, would it be possible to change the rendering to happen only when it's needed (for a particular frame, or only several frames ahead)?

I believe our animator could also optimize the animation in After Effects, reduce the number of layers, transparency etc. Actually it might be nice to have some notes about possible performance implications, and how to optimize it in After Effects.

Animation JSON

I understand we're probably an edge case here, but if you'd like to look at this anyway, I'll ask if I can share at least a part of the animation with you. Will probably send to your e-mail. Otherwise we'll have to use a video format or a static image.

@buba447
Copy link
Collaborator

buba447 commented Mar 28, 2019

Could you email me the animation to debug?

Just to clear things up for anyone that reads this in the future, Lottie is not rendering all of the frames up front. It is rendering them as it plays.

@JackPanda8
Copy link

i met this bug too.

2 similar comments
@wjwjwj2223
Copy link

i met this bug too.

@hydyy
Copy link

hydyy commented Jul 14, 2020

i met this bug too.

@calda
Copy link
Member

calda commented Jul 6, 2022

Today we released Lottie 3.4.0 which includes a new rendering engine powered by Core Animation (more details here). This new rendering engine has significantly better performance, and should resolve the performance issues folks have been encountering with the previous main thread rendering engine. Please try it out by setting the LottieConfiguration.renderingEngine feature flag, and feel free to report any new issues that you experience when using the new rendering engine.

@calda calda closed this as completed Jul 6, 2022
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

6 participants