Skip to content

Fix stale browser session in Custom Tab when Firefox is the default browser 🪿✨#13262

Open
michaelphines-stripe wants to merge 1 commit into
masterfrom
fix/custom-tab-share-state-off
Open

Fix stale browser session in Custom Tab when Firefox is the default browser 🪿✨#13262
michaelphines-stripe wants to merge 1 commit into
masterfrom
fix/custom-tab-share-state-off

Conversation

@michaelphines-stripe

@michaelphines-stripe michaelphines-stripe commented Jun 17, 2026

Copy link
Copy Markdown

Minion run

Summary

Set SHARE_STATE_OFF on the CustomTabsIntent.Builder in StripeConnectRedirectActivity when launching an external URL in a Custom Tab.

Motivation

When Firefox is set as the default browser on Android, CustomTabsIntent.Builder().build() (with the default SHARE_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_OFF is the documented mechanism for requesting a Custom Tab that is isolated from the browser's regular session, which is the correct behavior here.

Before:

val customTabsIntent = CustomTabsIntent.Builder().build()

After:

val customTabsIntent = CustomTabsIntent.Builder()
        .setShareState(CustomTabsIntent.SHARE_STATE_OFF)
        .build()

SHARE_STATE_OFF is available in androidx.browser:browser:1.2.0+; the project uses 1.9.0, so no dependency change is required.

Testing

  • Added tests
  • Modified tests
  • Manually verified

The existing StripeConnectRedirectActivityTest instrumented 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

[Fixed] Fixed an issue where users with Firefox set as their default browser would see a stale browser session instead of the intended URL when tapping external links inside embedded components.

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
@torrance-stripe torrance-stripe marked this pull request as ready for review June 30, 2026 14:46
@torrance-stripe torrance-stripe requested review from a team as code owners June 30, 2026 14:46
try {
val customTabsIntent = CustomTabsIntent.Builder().build()
val customTabsIntent = CustomTabsIntent.Builder()
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants