-
Notifications
You must be signed in to change notification settings - Fork 175
MotionLayout is crashing #526
Comments
Which Compose version is this? Haven't been able to repro on 1.0.0 or even 1.1.0. I'm using a very simple setup: @OptIn(ExperimentalMotionApi::class)
@Preview
@Composable
fun CrashTest() {
var sectionsState: Boolean by rememberSaveable { mutableStateOf(false) }
val collapsedSet = getCollapsedConstraints()
val expandedSet = getExpandedConstraints()
val progress by animateFloatAsState(
targetValue = if (sectionsState) 1f else 0f,
animationSpec = tween(150)
)
Column {
MotionLayout(
start = collapsedSet,
end = expandedSet,
progress = progress,
modifier = Modifier.fillMaxWidth().weight(1.0f, true),
) {
Text(
text = "My Title",
Modifier
.layoutId("title")
.background(Color.Red))
Text(
text = "My subtitle",
Modifier
.layoutId("subtitle")
.background(Color.Blue))
Text(
text = "TOGGLE",
Modifier
.layoutId("toggle")
.background(Color.Cyan))
Text(
text = "Sections",
Modifier
.layoutId("sections")
.background(Color.Yellow))
Text(
text = "Timers:",
Modifier
.layoutId("timers")
.background(Color.Gray))
}
Button(onClick = { sectionsState = !sectionsState }) {
Text(text = "Run")
}
}
} |
Any chance one of the Composables in MotionLayout has a size Modifier? (size, sizeIn, defaultMin, fillMaxSize, etc) Does it still crash with Dimension.fillToConstraints instead of Dimension.matchParent? |
Here is an example that shows the same error message, https://github.com/jipariz/ComposeMotion from the article, https://www.strv.com/blog/collapsing-toolbar-using-jetpack-compose-motion-layout-engineering. Based on this ComposeMotion project, update the followings:
Then compile and run. The exact same code works on older Compose versions, 1.0.1 and 1.04. However, it doesn't work with 1.1.1 with the error message. Thanks. |
No workaround other than sticking to 1.0.x It's a hard check that prevents us from remeasuring Composables during animation in some cases. I'll close this once we work out a solution with the rest of the Compose team. |
Issue seems to be resolved when using 1.2.0-alpha08 I'll keep this open until 1.2.0 hits stable or I'm able to guarantee no regressions from there. |
The motion layout is crashing with this error.
this is my code
The text was updated successfully, but these errors were encountered: