Missing InOverlay from ViewEnvironment, causes IllegalArgumentException from WorkflowSavedStateRegistryAggregator
rjrjr opened this issue · comments
Ray Ryan commented
https://workflow-community.slack.com/archives/CHTFPR277/p1657015240677379
From @bnvinay92:
I migrated from DialogBuilder (:see_no_evil:) to OverlayDialogFactory and I’m seeing this for just one of my dialogs:
java.lang.IllegalArgumentException: com.squareup.workflow1.ui.container.OverlayDialogHolder$Companion$NoOverlay+0 is already in use, it cannot be used to register DecorView@c9971a8[BookingActivity]
at com.squareup.workflow1.ui.androidx.WorkflowSavedStateRegistryAggregator.installChildRegistryOwnerOn(WorkflowSavedStateRegistryAggregator.kt:218)
This is happening when I try to show two overlays at a time or switch dialogs. I have a pretty simple BottomSheetDialog overlay factory:
override fun buildDialog(
initialRendering: BottomSheetDialogUiData,
initialEnvironment: ViewEnvironment,
context: Context
): OverlayDialogHolder<BottomSheetDialogUiData> {
val contextWrappedWithStyle = initialRendering.styleRes?.let { style -> ContextThemeWrapper(context, style) } ?: context
val contentView = WorkflowViewStub(contextWrappedWithStyle)
with(BottomSheetDialog(contextWrappedWithStyle)) {
setContentView(contentView)
behavior.addBottomSheetCallback(bottomSheetCallback())
return OverlayDialogHolder(initialEnvironment, this) { rendering, environment ->
setOnDismissListener { rendering.dismissListener() }
setOnCancelListener { rendering.cancelListener() }
setOnShowListener { rendering.showListener(behavior, this) }
contentView.update(
rendering.content, environment
.plus(DialogControlsKey to DialogControls(this))
.plus(BottomSheetBehaviorKey to behavior)
)
}
}
}
Am i supposed to add an InOverlay + initialRendering Pair to the environment before passing it to the holder? This does solve the crash but don’t know if there’s a reason it’s not the default?