Describe the bugrememberWindowState() causes a crash: java.lang.IllegalStateException: DpSize is unspecified
The relevant part of the stack trace is this:
at androidx.compose.ui.window.WindowStateImpl$Companion$Saver$1.invoke(WindowState.desktop.kt:230)
fun Saver(unspecifiedPosition: WindowPosition) = listSaver<WindowState, Any>(
save = {
listOf(
it.placement.ordinal,
it.isMinimized,
it.position.isSpecified,
it.position.x.value,
it.position.y.value,
it.size.width.value, // <-- Attempting a direct read of Dp.value,
it.size.height.value, // <-- which throws when Unspecified
)
},
.....
DpSize.Unspecified is a valid initial value for WindowState, but it appears that the state saver can't accommodate it. I am only seeing this crash within certain composable hierarchies, so perhaps there's a condition where the saver is invoked before the window has calculated its real size?
Affected platforms
Desktop (Windows, Linux, macOS)
Versions
Libraries:
Compose Multiplatform version: 1.6.2
Kotlin version: 1.9.22
OS version(s) (required for Desktop and iOS issues): Windows 11, up-to-date.
Describe the bug
rememberWindowState()
causes a crash:java.lang.IllegalStateException: DpSize is unspecified
The relevant part of the stack trace is this:
at androidx.compose.ui.window.WindowStateImpl$Companion$Saver$1.invoke(WindowState.desktop.kt:230)
DpSize.Unspecified
is a valid initial value for WindowState, but it appears that the state saver can't accommodate it. I am only seeing this crash within certain composable hierarchies, so perhaps there's a condition where the saver is invoked before the window has calculated its real size?Affected platforms
Versions
Libraries:
Kotlin version: 1.9.22
OS version(s) (required for Desktop and iOS issues): Windows 11, up-to-date.
OS architecture (x86 or arm64): x86
JDK (for desktop issues): Termurin 17
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Additional context This also affects
rememberDialogState
. The impact of this bug is that I'm unable to open dialogs from within lazy list items.As a workround,
remember { WindowState(size = DpSize.Unspecified) }
works, since it doesn't invoke rememberSaveable.