Android compose LazyRow inside LazyColumn gives junk behaviour
Asked Answered
S

0

10

I am trying to create one compose screen with nested scroll behaviour. For that I am using lazyColumn as parent and inside that I do have multiple rows with layRow.

val scrollState = rememberLazyListState()
LazyColumn(
    state = scrollState,
    modifier = Modifier
        .background(Color.White),
)
{
    items(100, key = { it })
    {
        LazyRow(
            contentPadding = PaddingValues(start = 16.dp, end = 16.dp),
            horizontalArrangement = Arrangement.spacedBy(10.dp)
        ) {

            items(10, key = { it }) {
                Text(text = "Text $it")
            }
        }
    }
}

I am getting lagging behaviour when I scroll the list. I tried to create release build and saw some improvement but the behaviour is still show some junk behaviour. Behaviour is different on different types of devices.

I tried to use Column as parent view and saw good improvement but it loads all the views in list together. Which cost some other delaying issues.

When I did macro-benchmarking found plenty of junky frames. Majority of them are requesting for render operation.

enter image description here

enter image description here

Any optimisation suggestion here?

Sloven answered 24/3, 2023 at 14:43 Comment(6)
What is the data size you used? Is it heavy UI with full images? Or this is happening with the basic code that u shared?Parisi
It is happening with the basic code which I have shared. The junk frames data is also for the same.Sloven
Can you try with your release builds once? I found this topic at the end of the lazy column page and figured out that sometimes it’s poor on performance during debug build but somehow it’s optimised on release developer.android.com/jetpack/compose/…, weird but something to give it a shot!Unheardof
Also see if R8 optimisation is in place or not.Unheardof
@JeelVankhede I tried in release build and there is some improvement in release build. But still it is not performant as recycler view. I can still see some frame drop logs in release build as well. R8 is also enabled.Sloven
Using Lazy for rows if your row items are small and its items are simple is just an overkill, IMHO consider using a simple Row for them.Galligaskins

© 2022 - 2024 — McMap. All rights reserved.