Add guard to prevent pw from dismissing on deep link#390
Merged
Conversation
superwall/src/main/java/com/superwall/sdk/paywall/view/PaywallView.kt
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes in this pull request
isPaywallPresentedbeing stuck in trueChecklist
CHANGELOG.mdfor any breaking changes, enhancements, or bug fixes.ktlintin the main directory and fixed any issues.Greptile Summary
This PR fixes a bug where
isPaywallPresentedwould remain stuck attrueindefinitely when a deep link (or any other trigger) caused theSuperwallPaywallActivityto finish while an in-app browser overlay was open (isBrowserViewPresented = true). The root cause was that bothbeforeOnDestroyanddestroyedhad an early-return guard that skipped all dismiss-lifecycle callbacks whenever the browser was presented — even when the activity was actually being destroyed.Key changes:
beforeOnDestroyanddestroyedinPaywallViewnow accept anisActivityFinishing: Boolean = falseparameter.isActivityFinishing = true, the browser-presented guard is bypassed sowillDismissPaywall/didDismissPaywalland state cleanup always execute on a real finish.SuperwallPaywallActivity.onPauseandonStoppassisFinishing(Android'sActivity.isFinishing()) to these methods, correctly distinguishing a transient lifecycle pause from an actual finish.false) preserves the existing behaviour for all other call sites (Compose, internalPaywallViewcalls) with no regressions.Minor notes:
PaywallComposable.kt) still calls both methods without arguments, so the sameisPaywallPresentedstuck-at-true scenario can theoretically occur for Compose-embedded paywalls when the browser is open at release time.isActivityFinishing = truebranch.CHANGELOG.mdwas not updated (checklist item unchecked).Confidence Score: 5/5
Safe to merge — the fix is well-scoped, backward-compatible, and correctly targets the stated bug; remaining finding is a pre-existing limitation in the Compose path that is out of scope for this PR.
All changed logic is guarded by a default-false parameter, so existing callers are completely unaffected. The Activity path correctly uses Android's isFinishing() API. The only open finding (Compose path not benefiting from the fix) is a pre-existing limitation rather than a regression introduced here, warranting P2 at most.
No files require special attention; the Compose composable (PaywallComposable.kt, unchanged in this PR) is the only place the same latent bug could surface.
Important Files Changed
Sequence Diagram
sequenceDiagram participant DL as Deep Link / Finish trigger participant SPA as SuperwallPaywallActivity participant PV as PaywallView participant SW as Superwall SDK Note over SPA,PV: isBrowserViewPresented = true (browser overlay open) DL->>SPA: finish() called (or back stack removed) SPA->>SPA: onPause() — isFinishing = true SPA->>PV: beforeOnDestroy(isActivityFinishing = true) Note over PV: Guard: isBrowserViewPresented && !true → false → proceeds PV->>SW: willDismissPaywall(info) SPA->>SPA: onStop() — isFinishing = true SPA->>PV: destroyed(isActivityFinishing = true) Note over PV: Guard: isBrowserViewPresented && !true → false → proceeds PV->>SW: didDismissPaywall(info) PV->>SW: isPaywallPresented = false ✅ Note over SPA,SW: Before fix: both calls would early-return,\nleaving isPaywallPresented stuck at true ❌Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "Add guard to prevent pw from dismissing ..." | Re-trigger Greptile