this might be a really obvious and common recompos...
# compose
j
this might be a really obvious and common recomposition issue, but can anyone point me in the right direction with this? • large list of data being loaded by LazyColumn (fills max height of screen) • when scrolling down, scroll is smooth and fast with no issues • when scrolling up, if any of the items in LazyColumn are taller than the screen itself, the scroll looks like it jitters and kind of gets “stuck” when it tries to scroll past those items • this jittering does not occur scrolling past smaller items, in that case going up is just as smooth as going down.. it’s only with taller items it feels like maybe recomposition is occurring, but I don’t quite understand it. any tips? does this sound familiar to someone?
👀 1
w
Recomposition of lazy columns comes up here a lot. I haven't heard of size impacting it. Have you tried it in release builds? The difference between dev and release especially with R8 is very significant.
I'd make sure you aren't doing recalculation, and if you think there is any chance that it is redrawing things that it shouldn't giving it a stable key might help. https://developer.android.com/jetpack/compose/lists#item-keys
j
thanks for the help @Will Shelor, when you say "recalculation" can you elaborate?
w
Sure! So ideally if you recompose a view while scrolling, it should be doing very little - just running the composition engine on a single view with relatively static content. I'd run it under the profiler and see if there is any business logic while scrolling other than just the compose drawing.
And again, with the drawing, it should be the composable coming into view and no others.
a
please file a bug!
👍 1
c
Please leave a link to the bug here. I think I've seen this too! I'd like to star.
a
I've been getting performance issues with LazyColumn and MotionLayout too.. not excessive items (30) and sample uses simple Text fields but noticeable stutter too. https://kotlinlang.slack.com/archives/CJLTWPH7S/p1634842131063300
w
ah, so this isn’t rendering stuttering, it’s like it’s redrawing and resizing when they come into view. Are you using item types?
j
thanks all for your input so far. I’ve drawn with highlighter on a still frame from that video to try and show the composable hierarchy • Yellow:
LazyColumn
items ◦ Red: 7 static `Row`s ▪︎ Blue (/purple): a variable amount of `Column`s, depending on data model
interestingly, if I change the count of the Blue
Columns
to be static, rather than
list.size
of the data model, the jumping around does not happen.. which leads me to think @Will Shelor is on the right track and this is a resizing issue that occurs
forgot to attach pic:
to those of you that had previously replied to this: any ideas what else I could try (based on the above picture describing the layout)?
w
If your list isn’t too long, you could move to Column instead of LazyColumn. If it does need to be lazy, I wonder if tagging your items with keys would help?
r
I’ve encountered this issue recently. I used LazyColumn to show image and chunks of long text I solved it giving a content type parameter