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

William Barbosa

08/12/2020, 2:15 PM
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

Adam Powell

08/12/2020, 2:15 PM
Can you post an example that experiences performance problems? The team would love to take a look.
t

Timo Drick

08/12/2020, 2:34 PM
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

William Barbosa

08/12/2020, 3:06 PM
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

alexsullivan114

08/12/2020, 10:40 PM
Sidenote: I love that toggls apps are open source. Awesome.
👍 1
❤️ 2
a

Alexandre Elias [G]

08/16/2020, 8:06 PM
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

William Barbosa

08/17/2020, 5:56 PM
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

Ali Zargar Shabestari

09/07/2020, 12:44 PM
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

FredyH

09/10/2020, 3:49 AM
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

Ali Zargar Shabestari

09/10/2020, 5:01 AM
@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.