question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add cache strategy feature

See original GitHub issue

Hello there 👋

It seems that it’s not possible to control how animations are cached by Lottie.

I’m using multiple Lottie animations in my app. All of them are cached in memory and take a lot a memory involving OutOfMemory errors. Currently, we can’t control which animation are cache in memory or disable this feature completely.

I’ve seen a lottie_cacheStrategy attribute in LottieAnimationView code but it doesn’t seem to exist anymore 😢 . Why has it been removed?

Here’s a sample of a memory dump showing the excessive amount of memory used by Lottie:

58666818-b46b9c00-8334-11e9-8d96-00070946de70

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:10

github_iconTop GitHub Comments

1reaction
timbru31commented, Jan 3, 2020

Unfortunately, URLs are still being cached and PR #1450 did not fix this. Let me quickly outline the problem. When the cacheKey is null, the cache function of the LottieCompositionFactory recognized and honors this case: https://github.com/airbnb/lottie-android/blob/ee942249214dd6bb1540b746ca0b678a6382b5ee/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java#L459-L474

Therefore a new network fetch is initiated, as it should be: https://github.com/airbnb/lottie-android/blob/ee942249214dd6bb1540b746ca0b678a6382b5ee/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java#L80-L88

However, the NetworkFetcher looks in it’s cache and returns the cached file, i.e., the end user still sees the wrong animation. IMHO the NetworkFetcher needs to be adjusted to honor the no cache flag, too: https://github.com/airbnb/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/network/NetworkFetcher.java#L42

0reactions
messi-wpycommented, May 14, 2020

there is no such things ,anyway i can’t find it . and lottie_cacheStrategy and cacheStrategy , it should have been removed. but in LottieCompositionFactory.fromUrl it still have LottieCompositionCache,however,it can’t control the size of local cache in appContext.getCacheDir()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching strategies - Amazon ElastiCache - AWS Documentation
The write-through strategy adds data or updates data in the cache whenever data is written to the database. Advantages and disadvantages of write-through....
Read more >
Set Up a Caching Strategy | MuleSoft Documentation
You can create a caching strategy from a Cache scope properties panel or a Global Elements configuration in Anypoint Studio. After you create...
Read more >
Working with the feature cache—ArcMap
First, pan and zoom your map to the area where you will be working. · On the main menu, click Customize > Toolbars...
Read more >
All things caching- use cases, benefits, strategies, choosing a ...
So in this post, I try to explain different parameters that help you decide a technology, also we discuss features & some real-world...
Read more >
Caching Strategies - CircleCI
Cache storage customization · Cache optimization · Partial dependency caching strategies · Caching strategy tradeoffs · Using a lock file · Using multiple...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found