airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
35.02k stars 5.41k forks source link

Lottie reports error "FileNotFoundException" due to error "ENAMETOOLONG (File name too long)" #2308

Closed LuciferTian2010 closed 1 year ago

LuciferTian2010 commented 1 year ago

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

If you don't use this template, your issue will be closed. Delete this text once completed.

Checklist

Checklist

  1. My animation doesn't use any unsupported features. ✅
  2. I know what part of my animation doesn't work. ✅
  3. I have created a simplified version of my animation ✅
  4. I have attached the AEP file (as a zip file so it can be attached) that only has the part of the animation that doesn't work. ✅

Describe the bug I have some Lottie files whose network uris are passed to LottieAnimationView.setAnimationFromUrl. Sometimes I see Lottie reports failure the error that "ENAMETOOLONG (File name too long)". The cache filenames seems generated based on the network uri. It is hard for us to shorten the network url for security purpose, so I am wondering if I can customize the way that Lottie uses to generate the filename of the cache file.

What version of Lottie did you test this on? 6.0.0

What version of Android did you test this on? Android 11

Steps To Reproduce n/a

Screenshots

gpeal commented 1 year ago

Yes, you can use LottieCompositionFactory.fromUrl with your own cacheKey

https://github.com/airbnb/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java#L126

LuciferTian2010 commented 1 year ago

Sorry I am new to Lottie, how does cacheKey used to generate the filename? From what I learn this cacheKey looks like used for memory cache not disk cache?

Also I narrow down to this function (https://github.com/airbnb/lottie-android/blob/master/lottie/src/main/java/com/airbnb/lottie/network/NetworkCache.java#L159) that generates the filename based on the url. And it looks like the function you mention would still use NetworkFetcher and NetworkFetcher uses NetworkCache which seems not resolve my problem?