-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Async Updates] First MVP of Async Updates #2276
Conversation
d29b0c4
to
d71ff51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
9a40f19
to
34d07fc
Compare
Can anyone please make a tiny sample of how to use it? Another possible scenario: |
@AndroidDeveloperLB I'm not sure if this will necessarily help. I would:
|
@gpeal Thank you, but is this what you suggest for the player, or for the conversion to MP4 ?
If for the player, I'm not sure if such a thing would suffice. |
@AndroidDeveloperLB I'm not really sure what you're asking. In general, if you're trying to do real time playback, you shouldn't do the bitmap rendering because it's software rendering. The default hardware rendering path will be much much faster. If you need to do something with the bitmaps like render them to mp4 then code similar to what you have is probably your best bet. |
@gpeal What I'm trying to have is a live wallpaper app, being able to show various kinds of content (color, image, animation and even video) in the center (center-crop) with ability to horizontally move. If you had wanted to show a Lottie animation (or animated GIF/WEBP), would you have chosen to directly show it by their libraries that can be drawn to a Bitmap, and then via the Canvas of the live wallpaper? If I use the playing solution of Lottie, and have a Bitmap being prepared in the background, wouldn't it be enough and the animation would be fluid? Sadly there aren't much tutorials for a live wallpaper for playing MP4 files . I had to ask this on StackOverflow after finding a bit broken app: As for converting to MP4 (from animated GIF/WEBP and Lottie) , I've also prepared something based on other's work, but I think it might have a bug too , because when I test it on a very few frames, I don't see some on the output video: |
@gpeal I can see api to enable async update for specific LottieAnimationView. Does lib support api to enable async updates for all the animations? Want to enable async update for Canary users. |
@aatishmittal194 I've gotten another request to add a global flag for it. I'll add it to |
@gpeal Can you please demonstrate it for a single one, though? |
@AndroidDeveloperLB |
@gpeal And that's it? Thank you! |
@AndroidDeveloperLB Yes that's it 😄 |
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:
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:
You can see setProgress being called immediately before draw.
This is what it looks like with async updates enabled:
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.