superwall / Superwall-iOS

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

[BUG] Crash in macOS when presenting the same Paywall twice #248

Open manuelescrig opened 2 weeks ago

manuelescrig commented 2 weeks ago

New issue checklist

General information

Describe the bug

Application crashes with the following error:

Application tried to present modally a view controller <SWKPaywallViewController: 0x1548b9800> that is already being presented by <UIViewController: 0x155867840>.

This happens when presenting a Paywall with the following code:

Superwall.shared.register(event: "event") { [weak self] in
    self?.continue()
}

Then the user dismissing the Paywall and then trying to present again the paywall calling the same code above. This happens only on the Mac Catalyst App. The issue doesn't happen on the iOS App.

Steps to reproduce

  1. Call the following code:
Superwall.shared.register(event: "event") { [weak self] in
    self?.continue()
}
  1. Dismiss the Pawyall
  2. Call the following code again
Superwall.shared.register(event: "event") { [weak self] in
    self?.continue()
}

Application crashes.

Other Information

Application tried to present modally a view controller <SWKPaywallViewController: 0x1548b9800> that is already being presented by <UIViewController: 0x155867840>. ( 0 CoreFoundation 0x00000001912762ec __exceptionPreprocess + 176 1 libobjc.A.dylib 0x0000000190d5a158 objc_exception_throw + 60 2 UIKitCore 0x00000001c0d48980 -[UIViewController _presentViewController:withAnimationController:completion:] + 4456 3 UIKitCore 0x00000001c0d4a3b8 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 88 4 UIKitCore 0x00000001c0d4b114 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 480 5 UIKitCore 0x00000001c0d4a324 -[UIViewController _presentViewController:animated:completion:] + 188 6 UIKitCore 0x00000001c0d4adf0 -[UIViewController presentViewController:animated:completion:] + 164 7 Email Me.debug.dylib 0x0000000105ac1ca4 $s12SuperwallKit21PaywallViewControllerC7present2on7request17unsavedOccurrence25presentationStyleOverride21paywallStatePublisher10completionySo06UIViewE0C_AA19PresentationRequestVAA011TriggerRuleJ0VSgAA0csL0OSg7Combine18PassthroughSubjectCyAA0cO0Os5NeverOGySbctF + 932 8 Email Me.debug.dylib 0x0000000105a61edc $s12SuperwallKit0A0C28presentPaywallViewController_2on17unsavedOccurrence9debugInfo7request21paywallStatePublisheryAA0deF0C_So06UIViewF0CAA011TriggerRuleI0VSgSDySSypGAA19PresentationRequestV7Combine18PassthroughSubjectCyAA0dN0Os5NeverOGtYaKFyScCyyts5Error_pGXEfU_ + 580 9 Email Me.debug.dylib 0x0000000105a62978 $ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlFyBcXEfU_ + 232 10 Email Me.debug.dylib 0x0000000105a62788 $ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlFTwBTY0_ + 148 11 Email Me.debug.dylib 0x0000000105a624ed $ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlFTwbTQ0_ + 1 12 Email Me.debug.dylib 0x0000000105a61939 $s12SuperwallKit0A0C28presentPaywallViewController_2on17unsavedOccurrence9debugInfo7request21paywallStatePublisheryAA0deF0C_So06UIViewF0CAA011TriggerRuleI0VSgSDySSypGAA19PresentationRequestV7Combine18PassthroughSubjectCyAA0dN0Os5NeverOGtYaKFTQ3_ + 1 13 Email Me.debug.dylib 0x0000000105a55809 $s12SuperwallKit0A0C17internallyPresentyyAA19PresentationRequestV_7Combine18PassthroughSubjectCyAA12PaywallStateOs5NeverOGtYaFTQ3_ + 1 14 Email Me.debug.dylib 0x0000000105a87279 $s12SuperwallKit0A0C22trackAndPresentPaywall33_B4AE92067A863DDE9C0AA24B951FA005LL8forEvent6params16paywallOverrides16isFeatureGatable9publisherySS_SDySSypGSgAA0fS0CSgSb7Combine18PassthroughSubjectCyAA0F5StateOs5NeverOGtYaFTQ3_ + 1 15 Email Me.debug.dylib 0x0000000105a86901 $s12SuperwallKit0A0C18internallyRegister33_B4AE92067A863DDE9C0AA24B951FA005LL5event6params7handler7featureySS_SDySSypGSgAA26PaywallPresentationHandlerCSgyycSgtFyyYacfU1_TQ3_ + 1 16 Email Me.debug.dylib 0x0000000105a86b65 $s12SuperwallKit0A0C18internallyRegister33_B4AE92067A863DDE9C0AA24B951FA005LL5event6params7handler7featureySS_SDySSypGSgAA26PaywallPresentationHandlerCSgyycSgtFyyYacfU1_TATQ0_ + 1 17 Email Me.debug.dylib 0x000000010583d581 $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ + 1 18 Email Me.debug.dylib 0x000000010583d6ed $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_ + 1 19 libswift_Concurrency.dylib 0x00000002589a20f9 _ZL23completeTaskWithClosurePN5swift12AsyncContextEPNS_10SwiftErrorE + 1 )

bugsnag_error_stacktrace_NSInvalidArgumentException_event_66fff5230100c7759bcb0000.txt

yusuftor commented 1 week ago

Hi, thanks for the report. I've been trying to reproduce this using the given steps but haven't been able to. Are you able to reproduce this in our example app? If so, can you attach a broken example project to this thread as that will really help solve the issue. Are you using getPaywall anywhere?