Hi Folks, I have been building a <slack clone with...
# compose-ios
a
Hi Folks, I have been building a slack clone with compose multiplatform with gRPC, I am facing an issue with compose UI crashing only on iOS with the following error :
Copy code
Uncaught Kotlin exception: kotlin.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
I am on latest version of compose jetbrains, Has anyone faced this before ?
Here's a video of the crash sad panda
p
I haven't seen it, sounds interesting what the message says. I would recommend opening an issue in the GitHub repo if you don't get a response here
a
Found a similar issue here and someone faced this on
1.3.1
too 🤔
same with Desktop and Android too 🤔
Copy code
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
	at androidx.compose.ui.node.NodeCoordinator.localToRoot-MK-Hz9U(NodeCoordinator.kt:885)
	at androidx.compose.foundation.text.TextFieldDelegate$Companion.notifyFocusedRect$foundation(TextFieldDelegate.kt:173)
	at androidx.compose.foundation.text.CoreTextFieldKt.notifyFocusedRect(CoreTextField.kt:1088)
	at androidx.compose.foundation.text.CoreTextFieldKt.access$notifyFocusedRect(CoreTextField.kt:1)
	at androidx.compose.foundation.text.CoreTextFieldKt$CoreTextField$5$1$1$2.measure-3p2s80s(CoreTextField.kt:621)
	at androidx.compose.ui.node.InnerNodeCoordinator.measure-BRTryo0(InnerNodeCoordinator.kt:103)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1090)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasure$2.invoke(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2201)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:238)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver$observeReads$1$1.invoke(SnapshotStateObserver.kt:234)
	at androidx.compose.runtime.SnapshotStateKt__DerivedStateKt.observeDerivedStateRecalculations(DerivedState.kt:341)
	at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(Unknown Source)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:120)
	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui(OwnerSnapshotObserver.kt:107)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1086)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:34
d
Hello! Thanks for bug description. The best way is to create a minimal reproducible sample of this crash. It means reproducing the bug with minimal amount of code. Click one button to reproduce. Can you please do so and share in on GitHub?
l
Hey there , I just had the same issue with this simple code : without the if part (which is the placeholder) it works just fine. But with the placeholder part, it crashes with the exception above when I clear str to empty string then type again. (Compose MP 1.4.0, Kotlin 1.8.20)
Copy code
val str = remember { mutableStateOf("") }
BasicTextField(
    value = str.value,
    onValueChange = { str.value = it },
    decorationBox = { innerTextField ->
        Row {
            if (str.value.isEmpty()) {
                Text("Aa")
            } else {
                innerTextField()
            }
        }
    }
)