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.05k stars 5.41k forks source link

Lags with many items in Grid RecyclerView #1463

Closed AlexMercier closed 4 years ago

AlexMercier commented 4 years ago

Hello. I have a RecyclerView with GridLayoutManager and its very lagging with 15 animations on screen. This is my own interpretation of Telegram stickers, but same animations have no lags on official telegram app on same device.

I record video with lags: https://youtu.be/vEQCcmkj2Sk No lags example in telegram app, playing smoothly: https://youtu.be/Bgdy3iTzNZw

i try to enable or disable hardware render mode but there is no difference.

This is code how I load animations from assets:

override fun onBindViewHolder(holder: StickerHolder, position: Int) {
        val filename = "json/${position+1}.json" 
        holder.lvSticker.setAnimation(filename)
        holder.lvSticker.playAnimation()
}

my animations: assets_dir.zip

Any solution to get rid of lags?

gpeal commented 4 years ago

@AlexMercier Telegram actually uses rlottie so it's hard to know without diving in. You can experiment with renderMode software and hardware. I just tried these out and in this case, it actually seems to render faster with software.