[Android] Fatal crash (FileNotFoundException) when loading .lottie from file:// URI (CodePush/OTA) on some devices
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start in LottieAnimationViewPropertyManager.kt, especially commitChanges and the file:// handler around lines 150–157, and compare it with the guarded block above. Verify the missing-file path is handled without opening a stream or crashing, while an available .lottie file still loads normally.
Written by the indexing model from the issue text.
Description
Description
Description
The file:// URI handler in LottieAnimationViewPropertyManager.kt (introduced by PR #1319 to support CodePush/OTA updates) opens a FileInputStream without checking if the file exists first. This causes an uncaught java.io.FileNotFoundException that fatally crashes the app on the main thread.
This is inconsistent with the code block immediately above it (lines 136–144), which correctly performs a file.exists() guard before opening.
The buggy code at lines 150–157:
if (scheme == "file") {
val uri = Uri.parse(assetName)
uri.path?.let { path ->
val fileWithScheme = File(path)
// ❌ No file.exists() check — crashes if file is unavailable
view.setAnimation(
ZipInputStream(FileInputStream(fileWithScheme)),
assetName.hashCode().toString()
)
}
}
Key observations
- The crash does not happen for all users. The same CodePush bundle works for the majority of users. Only a subset of users (likely those with slower I/O, low storage, or specific OEMs) hit this crash.
- CodePush hash verification confirms all files are present at install time, but the file can become transiently unavailable when the
LottieViewis pre-allocated during Fabric's frame callback on the next app restart. - Other React Native native components (e.g.,
Imagevia Fresco) handleFileNotFoundExceptiongracefully. OnlyLottieViewcrashes fatally because of the missing guard.
Crash log
FATAL EXCEPTION: main
Process: money.digital.payments, PID: 20659
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:610)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1005)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:600)
Caused by: java.io.FileNotFoundException:
/data/user/0/money.digital.payments/files/CodePush/.../CodePush/raw/src_assets_lottie_loader.lottie:
open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:574)
at java.io.FileInputStream.<init>(FileInputStream.java:179)
at com.airbnb.android.react.lottie.LottieAnimationViewPropertyManager.commitChanges(LottieAnimationViewPropertyManager.kt:155)
at com.airbnb.android.react.lottie.LottieAnimationViewManagerImpl.setSourceDotLottieURI(LottieAnimationViewManagerImpl.kt:205)
at com.airbnb.android.react.lottie.LottieAnimationViewManager.setSourceDotLottieURI(LottieAnimationViewManager.kt:143)
at com.facebook.react.viewmanagers.LottieAnimationViewManagerDelegate.setProperty(LottieAnimationViewManagerDelegate.java:44)
at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:103)
at com.facebook.react.uimanager.ViewManager.createViewInstance(ViewManager.java:230)
at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:148)
at com.facebook.react.fabric.mounting.SurfaceMountingManager.createViewUnsafe(SurfaceMountingManager.java:673)
at com.facebook.react.fabric.mounting.SurfaceMountingManager.preallocateView(SurfaceMountingManager.java:1083)
at com.facebook.react.fabric.mounting.mountitems.PreAllocateViewMountItem.execute(PreAllocateViewMountItem.kt:39)
at com.facebook.react.fabric.FabricUIManager$DispatchUIFrameCallback.doFrameGuarded(FabricUIManager.java:1513)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Linux.open(Native Method)
Suggested fix
Add a file.exists() check before the FileInputStream, consistent with the existing pattern at line 137:
if (scheme == "file") {
val uri = Uri.parse(assetName)
uri.path?.let { path ->
val fileWithScheme = File(path)
if (fileWithScheme.exists()) {
view.setAnimation(
ZipInputStream(FileInputStream(fileWithScheme)),
assetName.hashCode().toString()
)
} else {
Log.e(TAG, "Lottie file not found at path: $path (asset: $assetName). Skipping animation.")
}
} ?: Log.w(TAG, "URI path is null for asset: $assetName")
}
Related issues
- #1098 — original issue about dotLottie not working after CodePush
- #1319 — PR that introduced the
file://handler (which has this missing guard) - #1066 — crash when provided lottie link is broken
Environment
| Key | Value |
|---|---|
| lottie-react-native | 7.3.4 |
| react-native | 0.82.0 |
| Platform | Android |
| Architecture | Fabric (New Architecture) |
| Build type | Release app & production bundle |
| Device | Real device |
| OTA tool | CodePush |
Steps to reproduce
- Use lottie-react-native with .lottie files bundled via require() in a React Native app
- Push an OTA update via CodePush (or any OTA tool)
- Restart the app to apply the CodePush update
- Navigate to a screen that renders a using a .lottie asset
- On some devices (particularly lower-end or storage-constrained), the app crashes with FileNotFoundException
Snack or a link to a repository
N/A — This is a native-layer issue in LottieAnimationViewPropertyManager.kt that only manifests in OTA (CodePush/Expo Updates) scenarios on real devices, which cannot be reproduced in a Snack. The bug is visible by reading the source code at line 150-157 of LottieAnimationViewPropertyManager.kt where the file:// URI handler lacks a file.exists() check that is present in the block above (line 137).
Lottie React Native version
7.3.4
React Native version
0.82.0
Platforms
Android
Workflow
React Native
Architecture
Fabric (New Architecture)
Build type
Release app & production bundle
Device
Real device
Acknowledgements
Yes
- Dominant language
- TypeScript
- Stars
- 17.2k
- Forks
- 1.8k
- Avg merge
- 6h 50m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lottie-react-native/lottie-react-native
-
stale
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
lottie-react-native/lottie-react-native#1393 · 7 comments · 3 reactions ·
-
bug ios
Difficulty 4/5 3-5 days Newbie friendliness 25/100
lottie-react-native/lottie-react-native#1344 · 14 comments · 1 reaction ·
-
bug needs triage
lottie-react-native/lottie-react-native#1307 · 23 comments · 4 reactions · 1 assignee ·
-
android bug needs triage
lottie-react-native/lottie-react-native#1294 · 8 comments · 3 reactions · 1 assignee ·
-
bug
lottie-react-native/lottie-react-native#1178 · 5 comments · 1 assignee ·
All issues in lottie-react-native/lottie-react-native
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100