-
Notifications
You must be signed in to change notification settings - Fork 1
Use latest enableRenderCache from Lottie #2
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
base: main
Are you sure you want to change the base?
Conversation
|
Thx Xavier, will have a look at it next week and revert 👌 |
|
Hello @xvrh! Just tried it inside Presence and app crashed with this error. To reproduce it:
|
|
@delfme I'm not able to run your app on iOS. First I don't have access to your appstoreconnect team so I have to change the bundleId in the projects etc... I can have a look at your out-of-memory crash, but can you provide a runnable independent example? |
|
Maybe issue can be reproduced in this sample as well by loading 100 different animated stickers instead of using the same sticker. Can we add cacheSize: 60 ? |
|
@iosephmagno currently the cache is limited to 100MB: https://github.com/xvrh/lottie-flutter/blob/master/lib/src/render_cache.dart#L18. When this limit is reached, no other images are created (until some are released). When an animation disappear from the screen, it should release the memory immediately. To decide on the 100MB limit, I did my experiment with an iPhone Pro with a simplistic sample app. It seems I was too optimistic. We should probably lower the memory by default (50? 20?) and expose this property publicly so we can adapt this choice depending on the phone model. I'm also trying to validate that my assumptions are correct and that images are correctly disposed with no leak. One thing you should absolutely change in your settings, is remove the |
|
I released a new alpha version ie. void main() {
Lottie.renderCacheMaxMemory = 20000000;
}Can you try with some values for your app and see what works and what doesn't. If nothing works, then we may have a memory leak to find. |
|
Thx, will test it and revert. Usually a sticker zip file is 2-3Kb. Idk how lottie fileSize converts into memory, lets me just assume it gets 10 times bigger, so 2-300KB.
|
|
My doubt is about auto-evicting lotties from cache when they are not visible on the scene.
|
There is now 2 caches at 2 different levels:
Now I realise this RenderCache may not be useful to you. I can explore yet another intermediate solution. Instead of caching the rasterised images, I can just cache the drawing commands. It will take a lot less memory, save a CPU usage but NOT GPU usage. Maybe this will work for you. |
|
|
I just realized that we do pre-cache compositions (when stickers are downloaded form server) and then we pass cached compositions to Lottie. So maybe we are not really using plugin own's cache (1). |
Yes it is enabled by default. This cache is really the same as what we have with standard
It's a memory cache, so it's lost when app close. The system limit the cache to 1000 entry, then free the oldest entries. There is a
You can cache network assets in a persistent cache if you want. But this is not really the point of this cache.
Actually, it's not clear to me. The RenderCache is limited to 100MiB (in 3.0.0-alpha.1) and 50MB (in alpha.3). I expected to not crash with this limit. |
cc @iosephmagno
Lottiev3.0.0-alpha.1 has an experimentalenableRenderCachethat should replace any previous attempt (CacheLottieetc..)