Status Update
Comments
f....@gmail.com <f....@gmail.com> #2
I am using alpha12 and get the same crash and stack trace when using the Navigation component to navigate to any <dialog>
destination with a ComposeView
as the root view (the destination class is DialogFragment
).
So basically this seems to break dialog destinations with Compose.
A workaround is to change the destination from <dialog>
to <fragment>
type in the navigation.xml
, but then the previous fragment cannot be seen underneath the dialog, and 'dismiss on touch outside the dialog' doesn't work.
cl...@google.com <cl...@google.com>
ch...@google.com <ch...@google.com> #3
Also now hitting this in DialogFragment
like #2.
ch...@google.com <ch...@google.com> #4
Here's the simplest repro I could find:
Dialog(activity).apply {
val composeView = ComposeView(context)
composeView.setContent {
Text(text = "Crashy crashy")
}
setContentView(composeView)
}.show()
il...@google.com <il...@google.com> #5
Un-duping Dialog
case (i.e., dialogs not owned by a DialogFragment
) still needs to be addressed on the Compose side.
jb...@google.com <jb...@google.com> #6
I'll pass this over to adam for addressing the compose side.
jb...@google.com <jb...@google.com> #7
We addressed the DialogFragment issue in
Should be available from snapshots with build id 7166224
and switching your fragment dependency to 1.4.0-SNAPSHOT
if you wanted to try it out.
ad...@google.com <ad...@google.com> #8
We could try to synthesize a LifecycleOwner from other signals that ComposeView has available but it might get strange. The other view tree services will presumably be missing as well.
cl...@gmail.com <cl...@gmail.com> #9
I opened this stackoverflow question
UPDATE: using androidx.appcompat:appcompat:1.3.0-beta01 solved my issues. Would be great if this was added to the documentation
ad...@google.com <ad...@google.com> #10
The handling of the default window-scoped recomposer has changed significantly since this bug and several related issues addressed. If you experience similar issues please open a new bug to track its specifics.
li...@linkly.com.au <li...@linkly.com.au> #11
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from androidx.compose.ui.platform.ComposeView{f422538 V.E...... ......I. 0,0-0,0}
at androidx.compose.ui.internal.InlineClassHelperKt.throwIllegalStateExceptionForNullCheck(InlineClassHelper.kt:30)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer(WindowRecomposer.android.kt:466)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareWindowRecomposer$default(WindowRecomposer.android.kt:327)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.LifecycleAware$lambda$0(WindowRecomposer.android.kt:170)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion.$r8$lambda$FWAPLXs0qWMqekhMr83xkKattCY(WindowRecomposer.android.kt)
at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$$ExternalSyntheticLambda0.createRecomposer(D8$$SyntheticClass:0)
at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:226)
at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:302)
at androidx.compose.ui.platform.AbstractComposeView.resolveParentCompositionContext(ComposeView.android.kt:251)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:258)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:290)
at android.view.View.dispatchAttachedToWindow(View.java:15509)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2916)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1523)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1251)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6334)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:859)
Description
If you set a Fragment which has a
ComposeView
like so:You get the following crash: