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

Unable to parse composition, FileNotFoundException, Open failed: ENOENT (No such file or directory), Unexpected end of ZLIB input stream #2385

Closed NikitaMakhno closed 1 year ago

NikitaMakhno commented 1 year ago

Hi! Сould you help us with this problem?

We also encountered such an error: IllegalArgumentException: Unable to parse composition

   java.lang.IllegalArgumentException: Unable to parse composition
   at com.airbnb.lottie.LottieCompositionFactory.fromZipStreamSyncInternal(LottieCompositionFactory.java:509)
   at com.airbnb.lottie.LottieCompositionFactory.fromZipStreamSync(LottieCompositionFactory.java:447)
   at com.airbnb.lottie.network.NetworkFetcher.fromZipStream(NetworkFetcher.java:140)
   at com.airbnb.lottie.network.NetworkFetcher.fromInputStream(NetworkFetcher.java:119)
   at com.airbnb.lottie.network.NetworkFetcher.fetchFromNetwork(NetworkFetcher.java:84)
   at com.airbnb.lottie.network.NetworkFetcher.fetchSync(NetworkFetcher.java:45)
   at com.airbnb.lottie.LottieCompositionFactory.lambda$fromUrl$0(LottieCompositionFactory.java:128)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
   at java.lang.Thread.run(Thread.java:929)

All users get the same URL, but the error does not always occur, not for all users and is quite rare, and we do not yet know which URL it happens to, because we use a lot of animations.

Perhaps it has something to do with this error, since they occur about the same number of times:

   java.io.FileNotFoundException: /data/user/0/com.zvooq.openplay/cache/lottie_network_cache/lottie_cache_httpsservic443b486f114a64849009f9554087ccf5ceblottie.temp.zip: open failed: ENOENT (No such file or directory)
   at libcore.io.IoBridge.open(IoBridge.java:574)
   at java.io.FileInputStream.<init>(FileInputStream.java:160)
   at com.airbnb.lottie.network.NetworkFetcher.fromZipStream(NetworkFetcher.java:140)
   at com.airbnb.lottie.network.NetworkFetcher.fromInputStream(NetworkFetcher.java:119)
   at com.airbnb.lottie.network.NetworkFetcher.fetchFromNetwork(NetworkFetcher.java:84)
   at com.airbnb.lottie.network.NetworkFetcher.fetchSync(NetworkFetcher.java:45)
   at com.airbnb.lottie.LottieCompositionFactory.lambda$fromUrl$0(LottieCompositionFactory.java:128)
   at java.util.concurrent.FutureTask.run(FutureTask.java:264)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
   at java.lang.Thread.run(Thread.java:1012)

Or this one:

  Caused by android.system.ErrnoException: open failed: ENOENT (No such file or directory)
   at libcore.io.Linux.open(Linux.java)
   at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
   at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
   at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
   at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8253)
   at libcore.io.IoBridge.open(IoBridge.java:560)
   at java.io.FileInputStream.<init>(FileInputStream.java:160)
   at com.airbnb.lottie.network.NetworkFetcher.fromZipStream(NetworkFetcher.java:140)
   at com.airbnb.lottie.network.NetworkFetcher.fromInputStream(NetworkFetcher.java:119)
   at com.airbnb.lottie.network.NetworkFetcher.fetchFromNetwork(NetworkFetcher.java:84)
   at com.airbnb.lottie.network.NetworkFetcher.fetchSync(NetworkFetcher.java:45)
   at com.airbnb.lottie.LottieCompositionFactory.lambda$fromUrl$0(LottieCompositionFactory.java:128)
   at java.util.concurrent.FutureTask.run(FutureTask.java:264)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
   at java.lang.Thread.run(Thread.java:1012)

Or this one:

   java.io.EOFException: Unexpected end of ZLIB input stream
   at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:265)
   at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:178)
   at java.util.zip.ZipInputStream.read(ZipInputStream.java:209)
   at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:148)
   at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121)
   at com.airbnb.lottie.LottieCompositionFactory.fromZipStreamSyncInternal(LottieCompositionFactory.java:501)
   at com.airbnb.lottie.LottieCompositionFactory.fromZipStreamSync(LottieCompositionFactory.java:447)
   at com.airbnb.lottie.network.NetworkFetcher.fromZipStream(NetworkFetcher.java:140)
   at com.airbnb.lottie.network.NetworkFetcher.fromInputStream(NetworkFetcher.java:119)
   at com.airbnb.lottie.network.NetworkFetcher.fetchFromNetwork(NetworkFetcher.java:84)
   at com.airbnb.lottie.network.NetworkFetcher.fetchSync(NetworkFetcher.java:45)
   at com.airbnb.lottie.LottieCompositionFactory.lambda$fromUrl$0(LottieCompositionFactory.java:128)
   at java.util.concurrent.FutureTask.run(FutureTask.java:264)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
   at java.lang.Thread.run(Thread.java:1012)

Lottie version: 6.0.1

Android version: 7-13

gpeal commented 1 year ago

To be frank, using the built in networking APIs are always going to be a bit brittle. Networking is inherently flaky and three are many ways apps may want to handle retries, backoffs, etc. Instead, I would recommend either: 1 (recommended): Fetch the json/zip file using your own network stack and pass that to Lottie once it is downloaded and verified (maybe with an md5 hash or something) 2) Implement LottieNetworkFetcher and handle retries there. 3) Add a failure listener and handle errors yourself or retruy fetching the animation.

Unfortunately, there isn't much Lottie can do with a simple one-shot network API.