Hello team :wave: We seem to be getting a crash w...
# ios
m
Hello team 👋 We seem to be getting a crash with
Copy code
Fatal Exception: kotlin.IllegalStateException
Cannot attach layer if the view is not in the window hierarchy
which seems to be popping up in
ComposeHostingViewController
when presenting a
Dialog
. We haven't been able to reproduce this yet. Any ideas of what might be causing this, or how to mitigate the issue? Stack trace in the thread 🧵 >>> Thanks!
Copy code
Fatal Exception: kotlin.IllegalStateException

0  OURAPP                         0xfffd70 kfun:androidx.compose.ui.scene.ComposeHostingViewController.object-1.createPlatformLayer#internal + 132 (Preconditions.kt:132)
1  OURAPP                         0xf9cea4 kfun:androidx.compose.ui.scene.PlatformLayersComposeSceneImpl.createLayer#internal + 190 (PlatformLayersComposeScene.skiko.kt:190)
2  OURAPP                         0xf96e04 kfun:androidx.compose.ui.scene#rememberComposeSceneLayer(kotlin.Boolean;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}androidx.compose.ui.scene.ComposeSceneLayer + 263 (ComposeScene.skiko.kt:263)
3  OURAPP                         0xfab49c kfun:androidx.compose.ui.window.DialogLayout#internal + 196 (Dialog.skiko.kt:196)
4  OURAPP                         0xfa9d80 kfun:androidx.compose.ui.window#Dialog(kotlin.Function0<kotlin.Unit>;androidx.compose.ui.window.DialogProperties?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){} + 176 (Dialog.skiko.kt:176)
5  OURAPP                         0x1b871a4 kfun:com.ourapp.shared.core.ui.views#OurAppAlertDialog(kotlin.Function0<kotlin.Unit>;com.ourapp.shared.core.ui.views.OurAppDialogButtonConfig?;com.ourapp.shared.core.utils.IconSource?;kotlin.String?;kotlin.String?;androidx.compose.ui.graphics.Color?;androidx.compose.ui.text.TextStyle?;kotlin.String?;com.ourapp.shared.core.ui.views.OurAppDialogButtonConfig?;kotlin.Boolean;androidx.compose.ui.window.DialogProperties?;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int;kotlin.Int){} + 61 (OurAppAlertDialog.kt:61)
And
OurAppAlertDialog.kt:61
is just a call which creates a
Dialog
Copy code
Dialog(
  onDismissRequest = onDismissRequest,
  properties = properties,
) {
  ...
}
a
Hi! Could you please file an issue in out YouTrack?
You probably can fix the issue at the place where you're adding ComposeUIViewController to your app. Could you please show this code?
m
Sure! Created CMP-7536
a
Many thanks!
As a workaround, you can add small delay before showing the Dialog.
👍 1
m
Thanks for the info!