[Async Updates] First MVP of Async Updates (#2276)

This is the first MVP of async updates. This project is being funded by Airbnb Eng and likely wouldn't happen without their sponsorship.

The docs for the AsyncUpdates enum includes details on what is going on here but at a high level, Lottie has two hot paths:
1. setProgress
2. draw

This allows the former to happen off of them main thread _ immediately after_ draw completes so it is ready before the next one starts.

In many of my tests, the two paths were each accountable for ~50% of the total main thread work so this could reduce the main thread activity by ~50% or more.

Here is an example of systrace before:
<img width="1258" alt="CleanShot 2023-04-09 at 15 24 34@2x" src="https://user-images.githubusercontent.com/1307745/230800026-d73bf779-a109-46ee-9396-a54753860be4.png">

You can see setProgress being called immediately before draw.

This is what it looks like with async updates enabled:
<img width="1258" alt="CleanShot 2023-04-09 at 15 23 35@2x" src="https://user-images.githubusercontent.com/1307745/230800035-c6a2e02a-f47e-4cac-9394-4239ae27c524.png">

You can see that draw happens first and then setProgress for the _next frame_ happens immediately after on a different thread.

This is experimental and defaults to AUTOMATIC but AUTOMATIC will default to false until this API is stabilized.
11 files changed
tree: 30619ff5b7a3649fb710ee7a1d5136211244e955
  1. .github/
  2. .idea/
  3. After Effects Samples/
  4. gifs/
  5. gradle/
  6. images/
  7. issue-repro/
  8. issue-repro-compose/
  9. lottie/
  10. lottie-compose/
  11. sample/
  12. sample-compose/
  13. sample-compose-benchmark/
  14. snapshot-tests/
  15. .gitattributes
  16. .gitignore
  17. build.gradle
  18. CHANGELOG.md
  21. deploy_snapshot.sh
  23. gradle.properties
  24. gradlew
  25. gradlew.bat
  27. lint.xml
  28. post_pr_comment.js
  29. README.md
  30. RELEASE.md
  31. settings.gradle
  32. sign.sh
  33. upload_release.sh
  34. version.sh
  35. versions.properties

Lottie for Android, iOS, React Native, Web, and Windows

Build Status

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

Lead Sponsors

View documentation, FAQ, help, examples, and more at airbnb.io/lottie







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: lottieVersion

The latest stable Lottie-Compose version is: lottieVersion 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.