Fail to use ModalBottomSheet in bubbleCompose
snigle opened this issue · comments
Steps to reproduce
.bubbleCompose {
Surface(
modifier = Modifier
.fillMaxSize()
color = Color.Transparent
) {
ModalBottomSheet(
dragHandle = {},
onDismissRequest = { },
sheetState = SheetState(true, confirmValueChange = {_ -> false},skipHiddenState = true, initialValue = SheetValue.Expanded),
) {
Text("test")
}
}
}
minimize()
// Click on the bubble to close which do a removeAll()
minimize()
Expected behavior
Bubble reopen
Actual behavior
Throw an exception when trying to show bubble a second time.
Crash logs
FATAL EXCEPTION: main
Process: com.github.snigle.apptimer, PID: 11230
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1312)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:405)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
at androidx.compose.material3.ModalBottomSheetWindow.show(ModalBottomSheet.android.kt:534)
at androidx.compose.material3.ModalBottomSheet_androidKt$ModalBottomSheetPopup$1.invoke(ModalBottomSheet.android.kt:448)
at androidx.compose.material3.ModalBottomSheet_androidKt$ModalBottomSheetPopup$1.invoke(ModalBottomSheet.android.kt:447)
at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82)
at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1137)
at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:828)
at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:849)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:1041)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:520)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1191)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:133)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:183)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.kt:314)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.kt:192)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:140)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:133)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:1191)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:133)
at androidx.compose.ui.platform.Wrapper_androidKt.doSetContent(Wrapper.android.kt:104)
at androidx.compose.ui.platform.Wrapper_androidKt.setContent(Wrapper.android.kt:83)
at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:251)
at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:283)
at android.view.View.dispatchAttachedToWindow(View.java:21290)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3491)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3498)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2820)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2328)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9087)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
at android.view.Choreographer.doCallbacks(Choreographer.java:899)
at android.view.Choreographer.doFrame(Choreographer.java:832)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Floating-Bubble-View version
0.6.3
Android version
API 34
Device
Pixel 3a (emulated)
Other details
I successfully show the bubble twice with only using a Surface component. I don't know if I miss something ?
Acknowledgements
- I have searched the existing issues and this is a new ticket, NOT a duplicate or related to another open or closed issue.
- I have written a short but informative title.
- I have updated the library to the latest Version.
- I will fill out all of the requested information in this form.
Hello @snigle 👋,
I'm not sure what you want to achieve, but since we don't have an activity
, we are unable to use certain composables, such as ModelBottomSheet in your case.
If you have any problem, feel free to re-open the issue. Thanks 💖