Shopify / checkout-sheet-kit-android

Shopify’s Checkout Sheet Kit makes it simple to perform a checkout inside your Android app.
MIT License
12 stars 3 forks source link

addWebViewToContainer throws IllegalStateException #127

Closed mzielu closed 1 month ago

mzielu commented 2 months ago

What area is the issue related to?

Checkout Sheet Kit

What version of the package are you using?

3.0.1

Reproducible sample code

Sometimes (very rarely) I see that executing ShopifyCheckoutSheetKit.present() ends with an unexpected error. As I am reading logs it seems that in CheckoutDialog -> start() -> addWebViewToContainer() (line 90) -> addView (line 128) you are not executing removeView() on the child's parent first.

Steps to Reproduce

Trigger ShopifyCheckoutSheetKit.present()

Expected Behavior

Checkout should be opened without the error

Actual Behavior

Checkout is opened with the error

Screenshots/Videos/Log output

Fatal Exception: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner(ViewGroup.java:5477) at android.view.ViewGroup.addView(ViewGroup.java:5296) at android.view.ViewGroup.addView(ViewGroup.java:5268) at com.shopify.checkoutsheetkit.CheckoutDialog.addWebViewToContainer(CheckoutDialog.kt:128) at com.shopify.checkoutsheetkit.CheckoutDialog.start(CheckoutDialog.kt:90) at com.shopify.checkoutsheetkit.ShopifyCheckoutSheetKit.present(ShopifyCheckoutSheetKit.java:128) ...

Storefront domain

https://hobbii-as-euro.myshopify.com/