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

Mohamed Elfiky

10/20/2020, 4:02 AM
is this exception known
Layer is redrawn for LayoutNode in state NeedsRelayout
?
a

Andrey Kulikov

10/20/2020, 2:34 PM
no, it is not expected for sure. did you reproduce it on alpha05? could you please file a bug if you can stable reproduce it?
m

Mohamed Elfiky

10/20/2020, 3:53 PM
thanks, this is the code maybe something i am doing wrong
Copy code
@Composable
fun Test() {
    val state = rememberLazyListState()
    val selectedIndex = if (state.firstVisibleItemScrollOffset > 120) {
        state.firstVisibleItemIndex + 1
    } else {
        state.firstVisibleItemIndex
    }.coerceIn(0, 9)

    LazyRowForIndexed(
        items = (0..10).toList(),
        state = state,
    ) { index, item ->
            Card(
                modifier = Modifier
                    .padding(horizontal = 4.dp, vertical = 16.dp)
                    .width(
                        animate(target = if (selectedIndex == index) 200.dp else 100.dp)
                    )
                    .height(120.dp),
            ) {
                val imageId = when(index % 3) {
                    0 -> R.drawable.surffing_1
                    1 -> R.drawable.surrfing_2
                    else -> R.drawable.surffing_3
                }
                Image(
                    asset = imageResource(id = imageId),
                    contentScale = ContentScale.Crop
                )
            }
    }
}
when i remove the Image no crashes happens. should i file a bug?
a

Andrey Kulikov

10/20/2020, 4:37 PM
is it on alpha05?
m

Mohamed Elfiky

10/20/2020, 4:37 PM
yes
a

Andrey Kulikov

10/20/2020, 5:01 PM
Thanks. I filled a bug to investigate it: https://issuetracker.google.com/issues/171309350
m

Mohamed Elfiky

10/20/2020, 5:03 PM
thanks
should i file a bug from the beginning next time?
a

Andrey Kulikov

10/20/2020, 5:18 PM
it is completely fine to ask here first if it is a known issue already before filling
👍 1
v

Vincent tiensi

11/06/2020, 3:30 AM
Just wanted to chime in since I can’t seem to comment on the issue directly. I’m getting the same error with a LazyColumn. For additional error info
Layer is redrawn for LayoutNode in state NeedsRelayout [LayoutNode@80444f4 children: 0 measureBlocks: MeasuringIntrinsicsMeasureBlocks@f8be41d{ measureBlock=androidx.compose.foundation.ImageKt$Image$1$1@97f2692 }]
. It may possibly be image related, I haven’t looked to deeply into it but it happens intermittently as my list paginates.
a

Andrey Kulikov

11/06/2020, 11:07 AM
on what version of compose?
v

Vincent tiensi

11/09/2020, 12:15 AM
1.0.0-alpha06
is supposedly also an issue in the jetsnack sample app as well https://github.com/android/compose-samples/issues/236
a

Alexjlockwood

11/15/2020, 1:58 AM
i just started seeing the issue vincent is seeing as well on alpha07
j

JulianK

11/30/2020, 12:37 PM
I'm experiencing the same issue in alpha07. Didn't have this exception on alpha05 (skipped 06).
a

Andrey Kulikov

11/30/2020, 1:25 PM
it should be fixed in alpha08
a

allan.conda

12/01/2020, 12:03 PM
I’m getting slightly different error:
Layer is redrawn for LayoutNode in state NeedsRemeasure
Is this the same issue with same fix?
a

Andrey Kulikov

12/01/2020, 12:25 PM
most likely yes
a

allan.conda

12/01/2020, 12:26 PM
glad to hear! 🙏