canopas / compose-intro-showcase

Android - Highlight different features of the app using Jetpack Compose
https://canopas.github.io/compose-intro-showcase/
Other
484 stars 40 forks source link

Exception in ShowcaseContent #23

Closed aphex- closed 1 month ago

aphex- commented 10 months ago

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- commented 10 months ago

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

Blaizyr commented 4 months ago
  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.

dmitriy-chernysh commented 2 months ago

Sorry to say but I got a few crashes from users using v2.0.1

Fatal Exception: java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true at androidx.compose.ui.node.NodeCoordinator.getParentLayoutCoordinates(NodeCoordinator.kt:255) 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$ShowcaseContent$6.invoke(ShowcaseContent.kt:103) at com.canopas.lib.showcase.component.ShowcaseContentKt$ShowcaseContent$6.invoke(ShowcaseContent.kt:103) at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.java:192) at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2556) at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2827) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3314) at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3265) at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:940) at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1155) at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:127) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:583) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.java:551) at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41) at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.java:109) at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.java:41) at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1648) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1659) at android.view.Choreographer.doCallbacks(Choreographer.java:1129) at android.view.Choreographer.doFrame(Choreographer.java:1045) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1622) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8900) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

RuzickaOnd commented 1 month ago

When will this fix be released, please? Thanks

cp-megh-l commented 1 month ago

With v2.0.2, this crash is fixed!