Travis Griggs
08/04/2025, 5:37 PM// "Ideally, we would run measure and layout in separate snapshots, so it would be consistent throughout the pass, but that breaks some existing code, unfortunately.
// What you can do is make sure that the state that is used in items is only updated on the main thread." and then he offered the following modifier hack as well
// This should be used over LazyColumn IF (and probably only when) the items enumerated may be updated off of the main tread
@Composable
fun ThreadSafeLazyColumn(
modifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
content: LazyListScope.() -> Unit,
) {
LazyColumn(modifier = modifier.layout { m, c ->
val placeable = Snapshot.withMutableSnapshot { m.measure(c) }
layout(placeable.width, placeable.height) { placeable.place(IntOffset.Zero) }
}, state = state, contentPadding = contentPadding, content = content)
}
Updating my app to all of the new versions, I'm wondering if this is still necessary? Or if newer versions have addressed these layout issues.Zach Klippenstein (he/him) [MOD]
08/04/2025, 5:41 PMTravis Griggs
08/04/2025, 5:51 PMZach Klippenstein (he/him) [MOD]
08/04/2025, 5:53 PMshikasd
08/04/2025, 7:21 PMderivedStateOf
, but I don't see how we can fix it without removing derivedStateOf
completely.Zach Klippenstein (he/him) [MOD]
08/04/2025, 8:25 PMshikasd
08/04/2025, 8:40 PMTravis Griggs
08/04/2025, 9:08 PMTravis Griggs
08/04/2025, 9:09 PMshikasd
08/05/2025, 12:40 AMZach Klippenstein (he/him) [MOD]
08/05/2025, 1:26 AM