Fix stale browser session in Custom Tab when Firefox is the default browser 🪿✨#13262
Open
michaelphines-stripe wants to merge 1 commit into
Open
Fix stale browser session in Custom Tab when Firefox is the default browser 🪿✨#13262michaelphines-stripe wants to merge 1 commit into
michaelphines-stripe wants to merge 1 commit into
Conversation
Setting SHARE_STATE_OFF on the CustomTabsIntent.Builder prevents browsers like Firefox from surfacing a restored session tab instead of navigating to the requested URL. With the default SHARE_STATE_DEFAULT, Firefox for Android's Custom Tabs implementation can show a previously-open tab (restored from its session) instead of loading the URL passed in the intent. Setting SHARE_STATE_OFF explicitly requests an isolated Custom Tab that is independent of the browser's regular session. Committed-By-Agent: goose
| try { | ||
| val customTabsIntent = CustomTabsIntent.Builder().build() | ||
| val customTabsIntent = CustomTabsIntent.Builder() | ||
| .setShareState(CustomTabsIntent.SHARE_STATE_OFF) |
There was a problem hiding this comment.
According to the documentation, SHARE_STATE_OFF controls whether Share button is displayed or not
Explicitly does not show a share option in the tab.
Which is completely unrelated to what you wrote in the PR.
SHARE_STATE_OFF is the documented mechanism for requesting a Custom Tab that is isolated from the browser's regular session
Did you test that this really fixes the issue? If it does, it sounds more like a Firefox glitch than an official fix.
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.
Minion run
Summary
Set
SHARE_STATE_OFFon theCustomTabsIntent.BuilderinStripeConnectRedirectActivitywhen launching an external URL in a Custom Tab.Motivation
When Firefox is set as the default browser on Android,
CustomTabsIntent.Builder().build()(with the defaultSHARE_STATE_DEFAULT) causes Firefox to surface its restored browser session — i.e. whatever tab was last open — instead of navigating to the URL passed in the intent. This means users whose default browser is Firefox may see a stale, unrelated page instead of the intended destination (e.g. a Stripe support or documentation link opened from within an embedded component).The symptom persists across reboots because Firefox aggressively restores its session on launch. Repeated taps stack multiple Firefox tasks, each requiring a separate back-press to dismiss. Switching the default browser to Chrome resolves it entirely, confirming this is Firefox-specific behavior under
SHARE_STATE_DEFAULT.SHARE_STATE_OFFis the documented mechanism for requesting a Custom Tab that is isolated from the browser's regular session, which is the correct behavior here.Before:
After:
SHARE_STATE_OFFis available inandroidx.browser:browser:1.2.0+; the project uses1.9.0, so no dependency change is required.Testing
The existing
StripeConnectRedirectActivityTestinstrumented tests cover that the Custom Tab intent is fired with the correct URL. The change is a single-field addition to the intent builder and does not alter the activity's lifecycle or redirect behaviour.Screenshots
N/A — this fix affects browser session behaviour rather than any UI within the app.
Changelog