compose-intro-showcase icon indicating copy to clipboard operation
compose-intro-showcase copied to clipboard

Exception in ShowcaseContent

Open aphex- opened this issue 2 years ago • 1 comments

Hello. I am getting the following exception:

 java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
     at androidx.compose.ui.node.NodeCoordinator.getParentLayoutCoordinates(NodeCoordinator.kt:256)
     at androidx.compose.ui.layout.LayoutCoordinatesKt.findRootCoordinates(LayoutCoordinates.kt:180)
     at androidx.compose.ui.layout.LayoutCoordinatesKt.boundsInWindow(LayoutCoordinates.kt:134)
     at com.canopas.lib.showcase.component.ShowcaseContentKt.ShowcaseContent(ShowcaseContent.kt:76)
     at com.canopas.lib.showcase.component.ShowcaseContentKt$ShowcasePopup$1$1.invoke(ShowcaseContent.kt:55)
     at com.canopas.lib.showcase.component.ShowcaseContentKt$ShowcasePopup$1$1.invoke(ShowcaseContent.kt:54)

If I debug into the code I can confirm that the 'targetCords.isAttached' is false and the call of 'targetCords.boundsInWindow()' leads to the exception.

My guess is it has something to do with the fact that I am using a LazyColum. But anyway.. It might be better to handle the 'isAttached == false' case in the library than letting the app crash?

aphex- avatar Jan 14 '24 11:01 aphex-

Okey this also happens in other situations for example if I want to target a Composable in a 'trailingIcon' of a TextField

aphex- avatar Jan 14 '24 16:01 aphex-

  1. my sc implementation goes through three different views.
  2. the first passthrough is always correct,
  3. but at the end of the whole sequence, if I reset the showcase state and jump to the beginning - every transition between already composed views - results in this exception. In general - every time the showcase increments to the target already composed element on a separate view - the application crashes.

I think instead of trying to consume the coordinates of a composable that was previously drawn, it should force a re-composition or something like that.

Blaizyr avatar Jul 17 '24 08:07 Blaizyr