https://kotlinlang.org logo
#compose
Title
# compose
c

Chris Fillmore

10/26/2021, 4:52 PM
I have a
LazyColumn
with around ~75 items, including `stickyHeader`s, inside a bottom sheet, and the performance of
LazyListState.animateScrollToItem()
is noticeably bad. The animation is not smooth; it appears to just show a few frames before landing at the target index. Scrolling through the list manually otherwise works well enough. The items in the list have some state associated with them (they can be “favourited” (via a heart icon) or “toggled” (via a switch). They have other components which are visible (or interactive) conditionally. So they are perhaps relatively complex. Should I expect
animateScrollToItem
to be performant in this case? I’m wondering if others have encountered a similar situation. Thanks for the feedback.
a

Adam Powell

10/26/2021, 6:38 PM
do you notice a difference between animating programmatically and touch-flinging at a similar speed?
c

Chris Fillmore

10/26/2021, 7:08 PM
No, at least to me it appears similar when I animate vs fling.
Actually, I tested some more and it seems inconsistent. Sometimes the fling looks ok (not perfectly smooth but not noticeably bad.)
a

Adam Powell

10/27/2021, 2:04 PM
Are you running a release build? Do you see this behavior the first few times and then it settles?
c

Chris Fillmore

10/27/2021, 2:09 PM
Yes I started testing with a release build after reading that that made a difference. I’m not sure I noticed much difference in release vs debug, but I’ll check again. What to make of the suggestion of setting
minifyEnabled true
and using
proguard-android.txt
instead of
proguard-android-optimize.txt
? https://www.reddit.com/r/androiddev/comments/n61qxh/jetpack_compose_lazycolumn_laggy/h8b9c8m/?utm_source=reddit&utm_medium=web2x&context=3 I did test these changes but did not observe a noticeable difference.
a

Adam Powell

10/27/2021, 2:21 PM
If you notice it gets smoother after a few scrolls in the same run of the app you might be seeing jit compilation. We should be publishing some new docs soon on the baseline profile installation process we use such that end users generally never see this, and you can trigger the ahead of time compilation process manually for development testing
If it doesn't get smoother after a few scrolls, then you'll probably want to investigate your composables that make up each item
c

Chris Fillmore

10/27/2021, 2:23 PM
Thanks for the feedback. I will probably circle back to working on this next week, since the component otherwise needs some input from a teammate.
👍 1
f

fabio.carballo

10/27/2021, 7:21 PM
just putting myself here - because I came looking for the exact same problem.
7 Views