superwall / Superwall-iOS

Remotely configure every aspect of your paywall and double your revenue.
https://superwall.com
MIT License
82 stars 22 forks source link

[BUG] It seems that in Mac Catalyst SwiftUI app, after closing a Superwall opened on app start, the whole app becomes unresponsive to clicks! #192

Closed tkafka closed 6 months ago

tkafka commented 6 months ago

New issue checklist

General information

Describe the bug

I have an iOS app that is also built as a Mac Catalyst app for macs (both intel and Apple Silicon). I am using Superwall, and it is configured to show on app activate (unless the app is purchased). This works great on iOS (both device and simulator), but when I run the exact same code on the mac, the app UI is blocked after closing the paywall.

Specifically, scrolling works, but any clicks (like button clicks) do not. The app behaves as if there was some invisible layer eating all clicks after closing the Superwall webview.

Steps to reproduce

Other Information

These are Superwall logs I see in Xcode console. I tried to get more info about A JavaScript exception occurred, but it doesn't show up when debugging the webview in Safari debug mode, so it seems like this is happening when Superwall reads the values from the webview? But anyway, I get the same messages in iOS, and the app works fine there after closing the superwall.

▿ 2024-01-19T23:49:05.997Z ‼️ [Superwall] [paywallPresentation] - ERROR: Paywall Already Presented: 1 key/value pair
  ▿ (2 elements)
    - key: "info"
    ▿ value: 1 key/value pair
      ▿ (2 elements)
        - key: "message"
        - value: "Superwall.shared.isPaywallPresented is true"
2024-01-19T23:49:05.998Z ℹ️ [Superwall] [paywallPresentation] - INFO: Skipped paywall presentation: paywall_already_presented
▿ 2024-01-19T23:49:05.999Z ‼️ [Superwall] [paywallPresentation] - ERROR: Paywall Already Presented: 1 key/value pair
  ▿ (2 elements)
    - key: "info"
    ▿ value: 1 key/value pair
      ▿ (2 elements)
        - key: "message"
        - value: "Superwall.shared.isPaywallPresented is true"
2024-01-19T23:49:05.999Z ℹ️ [Superwall] [paywallPresentation] - INFO: Skipped paywall presentation: paywall_already_presented
▿ 2024-01-19T23:49:06.012Z ‼️ [Superwall] [paywallViewController] - ERROR: Error Evaluating JS: 2 key/value pairs
  ▿ (2 elements)
    - key: "info"
    ▿ value: 1 key/value pair
      ▿ (2 elements)
        - key: "message"
        - value: "  window.paywall.accept64(\'W3sicGF5d2FsbF9pZGVudGlmaWVyIjoieWYtcmVkZWVtLWRlbW9jb250ZW50LTg5MDEtMjAyMy0wNS0yNCIsInBheXdhbGxfaWQiOiI3NjU0IiwiZXZlbnRfbmFtZSI6InBheXdhbGxfb3BlbiJ9XQ==\');"
  ▿ (2 elements)
    - key: "error"
    - value: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=0, WKJavaScriptExceptionMessage=TypeError: undefined is not an object, WKJavaScriptExceptionColumnNumber=0, NSLocalizedDescription=A JavaScript exception occurred} #0
      - super: NSObject
tkafka commented 6 months ago

As setting up a new app with a separate Superwall is a bit tedious, I would appreciate if you could first try enabling building as Mac Catalyst app for some of your testing apps, and see if you can reproduce the issue there. If not, I will see if I can create a minimal reproduction sample, but so far it seems that just running any SwiftUI Superwall enabled app as Mac Catalyst mac app should trigger this.

yusuftor commented 6 months ago

Hey, thanks for reporting. I'm not able to reproduce following the steps you've provided. I tried this within our SwiftUI sample app. Are you able to reproduce within our sample app? I also tried both with an app_launch trigger and just a button to open the paywall.

yusuftor commented 6 months ago

Realised I was on a slightly older version of Sonoma. I updated my mac and found the issue. When we present a paywall we create a new UIWindow to present from. This wasn't being removed correctly on Mac. This is fixed and will be included in the next release, thanks for reporting!

tkafka commented 6 months ago

Awesome, thank you!