commit | f38d0df5b1ea7403ad08789955580f8df974852a | [log] [tgz] |
---|---|---|
author | Wenbin Liu <liuwenbin168@126.com> | Tue Dec 14 06:46:19 2021 +0800 |
committer | GitHub <noreply@github.com> | Mon Dec 13 14:46:19 2021 -0800 |
tree | 4bc7dbd8ddc483914228fec3a76514e5d9819f5b | |
parent | 3b5387ab6a95e59f6c3f44ba9fd97c986982b33e [diff] |
Fix a potential NPE race conditions (#1959) This PR addresses the issue #1958 , although the crash is pretty hard to reproducible, the enhancement will definitely make it more robust. The issue was in com.airbnb.lottie.LottieDrawable#buildCompositionLayer method. The related code is: private void buildCompositionLayer() { compositionLayer = new CompositionLayer( this, LayerParser.parse(composition), composition.getLayers(), composition); if (outlineMasksAndMattes) { compositionLayer.setOutlineMasksAndMattes(true); } } The crash exception stack prints: Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.airbnb.lottie.LottieComposition.getLayers()' on a null object reference at com.airbnb.lottie.LottieDrawable.buildCompositionLayer(LottieDrawable.java:298) ... As we can see, the exception occurs at composition.getLayers(), but before executing this statement, the LayerParser.parse(composition) statement also refers to the composition object, which was fine, but after that this object had been set to null, thus caused NPE. I think this issue is very similar to the issues resolved in PR #1917
Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as json with Bodymovin and renders them natively on mobile!
For the first time, designers can create and ship beautiful animations without an engineer painstakingly recreating it by hand. They say a picture is worth 1,000 words so here are 13,000:
Lottie is maintained and improved on nights and weekends. If you use Lottie in your app, please consider sponsoring it to help ensure that we can continue to improve the project we love. Click the sponsor button above to learn more
Gradle is the only supported build configuration, so just add the dependency to your project build.gradle
file:
dependencies { implementation 'com.airbnb.android:lottie:$lottieVersion' }
The latest Lottie version is:
The latest stable Lottie-Compose version is: Click here for more information on Lottie-Compose.
Lottie 2.8.0 and above only supports projects that have been migrated to androidx. For more information, read Google's migration guide.
Because development has started for Lottie Compose, Gradle, and the Android Gradle Plugin will be kept up to date with the latest canaries. This also requires you to use Android Studio Canary builds. Preview builds can be installed side by side with stable versions.