https://kotlinlang.org logo
Title
m

mcpiroman

07/20/2021, 3:17 PM
Hi, When I insert an item into list displayed via `Column`all subsequent elements are recomposed, meaning that if I insert at the end everything's fine but when I insert at the beginning there is a huge delay. Doesn't matter if I use `mutableStateOf`or
mutableStateListOf
, whether I use `key`function or not (though it does feel like it affects performance somewhat). I don't use `LazyColumn`because it is laggy in general. Known problem, walkaround? Thanks.
d

Dominaezzz

07/20/2021, 4:06 PM
Not fixes for that really. You asked
Column
to remeasure everything by inserting at the top. You'd need to use a
LazyColumn
if you want to skip recomposition of non-visible items.
How is it laggy?
m

mcpiroman

07/20/2021, 4:30 PM
`LazyComunm`lags when scrolling (it is often ok with scrollwheel but not when dragging the scrollbar). But now that I switched my simplified testing example to `LazyColumn`I see that at least the performance of insertion is acceptable. I may have to try with maybe keys or something in my main case where it could took line a second to insert something. FYI the list has about 300 items consisting of `Text`and
Icon
, it is just adapted tree view from CodeViewer example.
But`Column`could eventually overcome that right? If the elements below do not change, they do not change height so they could be just shifted down without recomposition?
d

Dominaezzz

07/20/2021, 4:46 PM
Nope, you need subcomposition to do that. Which
Column
doesn't do.
Yeah scrollbars are hard. You're saying your scrollbars aren't laggy on
Column
?
Are the sizes of your items very different?
m

mcpiroman

07/20/2021, 5:01 PM
All items are the same size, single line of text. Yes, unlike on `LazyColumn`with `Columns`scrolling is smooth.