Any tips on improving the performance of `LazyColu...
# compose
w
Any tips on improving the performance of
LazyColumnFor
? Even when the items are really flat the scrolling feels really jaggy. Is performance something that will be looked before the final release or am I holding it wrong?
a
Can you post an example that experiences performance problems? The team would love to take a look.
t
The performance of the LazyColumnFor itself is good. But of course it depends on how you draw the items. So in my tests also displaying images still works smooth when you do it the right way.
w
Hey, Adam ๐Ÿ™‚ We are currently using it in our settings view as a contained experiment. You can see the actual code here, we're OSS The actual structure is:
Copy code
LazyColumn
  Column
    Text
    Row
      Text
      Switch
๐Ÿ‘ 1
a
Sidenote: I love that toggls apps are open source. Awesome.
๐Ÿ‘ 1
โค๏ธ 2
a
Hi, I'm another compose team member working on (among other things) LazyColumn. Thanks for the github link, I inspected it and did not see any obvious performance antipattern on your end. That this not scroll at 60fps I would consider this a performance bug on our end that we plan to fix before Compose 1.0
๐ŸŽ‰ 1
We do have a lot of plans to improve LazyColumn performance. On the one hand, we plan to just microoptimize a lot of things (actually, much of this is in compose compiler or components like Text, but the stress test of LazyColumn means it will be especially visible there). On the other hand, we plan to create an asynchronous prefetch system in LazyColumn in order to pay perf costs elsewhere (loading, or ideally on other cores without slowing anything down for the user) instead of causing scroll janks
๐Ÿ‘ 1
Thanks for the report and the open-source code. I'll keep a link to your app code to sanity check our performance efforts
๐Ÿ‘ 1
w
Thanks a bunch, Alexandre ๐Ÿ™Œ Compose looks amazing and it's really great to see such a commitment from Google to make it even better
๐Ÿค— 1
a
I have the same performance problem as well, here is the code:
Copy code
LazyColumnFor(items = entries.words) {
    Card(
            modifier = Modifier
                    .fillMaxWidth()
                    .padding(5.dp)
                    .clickable(onClick = {
                        navigateTo(Screen.Definition(it.word))
                    })
    ) {
        Text(
                text = it.word,
                style = TextStyle(fontWeight = FontWeight.Bold),
                modifier = Modifier.padding(10.dp)
        )
    }
}
not using
Card
fixes the performance problem though. Edit: Actually it has something to do with
clickable
modifier.
f
I have also encountered this issue, and it does indeed seem that having clickable things inside a LazyColumnFor seems to be causing massive performance issues. However, even without the clickable modifier, the performance is still significantly worse than just a static column.
a
@FredyH I have filed a bug report here: https://issuetracker.google.com/issues/167972292 I realized that it only happens when I build for a physical device not the emulator. Please add your environment that you experience the same issue to the bug report above.