Skip to content

Fire Mode: WebView profile management#8575

Open
0nko wants to merge 23 commits into
developfrom
feature/ondrej/fire-mode-webview-profiles
Open

Fire Mode: WebView profile management#8575
0nko wants to merge 23 commits into
developfrom
feature/ondrej/fire-mode-webview-profiles

Conversation

@0nko
Copy link
Copy Markdown
Member

@0nko 0nko commented May 15, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/1207418217763355/task/1214780084779090?focus=true

Description

Isolates WebView state between Regular and Fire browser modes via AndroidX webkit's MULTI_PROFILE API. Each newly-created WebView is bound to its mode-specific androidx.webkit.Profile so cookies, LocalStorage, IndexedDB, and other origin-keyed storage are partitioned per mode. No-op on devices without MultiProfile support.

BrowserTabFragment injects WebViewProfileBinder and calls bind(it, browserMode) inside configureWebView() immediately after inflating the DuckDuckGoWebView, before any settings are applied.

API proposal: WebViewProfileBinder interface

Steps to test this PR

  • Smoke test the app and make sure data-clearing works as before. There should be no change to any user-visible functionality

Note

Medium Risk
Changes when and how WebViews are profile-bound and how Fire availability is computed; mistakes in bind ordering or profile selection could affect cookie/storage isolation or Fire behavior.

Overview
This PR wires Fire vs Regular browser modes to separate AndroidX WebView profiles when MULTI_PROFILE is supported, so cookies and origin storage (LocalStorage, IndexedDB, etc.) can stay partitioned per mode.

A new WebViewModeInitializer is called from BrowserTabFragment right after the tab WebView is inflated and before any other WebView setup, binding the view to the profile for the current BrowserMode (REGULAR uses the default profile; FIRE uses a dedicated "Fire" profile). RealWebViewModeInitializer no-ops when Fire/multi-profile is unavailable.

WebStorageProvider resolves per-mode WebStorage via ProfileStore when multi-profile is on, otherwise the shared default instance. BrowserMode.profileName centralizes the profile name mapping.

FireModeAvailability is now synchronous (no longer suspend), caches availability at process start and on first read, and checks WebViewFeature.MULTI_PROFILE plus the Fire tabs flag instead of WebViewCapabilityChecker. Tests were adjusted for the new caching and sync API.

Reviewed by Cursor Bugbot for commit ba1044a. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member Author

0nko commented May 15, 2026

@0nko 0nko assigned 0nko and CDRussell and unassigned 0nko May 15, 2026
@0nko 0nko requested a review from CDRussell May 15, 2026 11:30
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from 9db5ee6 to c9ed552 Compare May 15, 2026 11:32

@Volatile
private var multiProfileSupported: Boolean? = null
private var cachedAvailability: Boolean? = null
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The availability is cached because if the flag changed mid-run, different profiles might be used, which could result in unexpected behavior.

@0nko 0nko force-pushed the feature/ondrej/fire-mode-rename-modules branch from edcf6dd to 19ab411 Compare May 15, 2026 12:36
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from 3a41216 to 7819973 Compare May 15, 2026 12:36
Base automatically changed from feature/ondrej/fire-mode-rename-modules to develop May 15, 2026 13:00
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from c396ec1 to 40ff4c5 Compare May 15, 2026 13:05
Comment thread browser-mode/browser-mode-impl/build.gradle Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b1c4058. Configure here.

Comment thread app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt Outdated
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch 2 times, most recently from 4a8d539 to f843786 Compare May 18, 2026 07:54
@0nko 0nko mentioned this pull request May 18, 2026
5 tasks
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from f843786 to b7e580f Compare May 18, 2026 18:54
@0nko 0nko mentioned this pull request May 18, 2026
33 tasks
@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from b7e580f to 70343bf Compare May 18, 2026 22:07
Copy link
Copy Markdown
Member

@CDRussell CDRussell left a comment

Choose a reason for hiding this comment

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

Smoke tested and it looked ok to me. Reluctant to approve the PR if the public API changes are not covered in a proposal, though. which I didn't think they were (maybe I misremember); are they covered? Because if not, probably will result in changes to these again before merging.

* No-op on devices that do not support the `MULTI_PROFILE` WebView feature; such callers
* implicitly share the default profile across modes.
*/
interface WebViewProfileBinder {
Copy link
Copy Markdown
Member

@CDRussell CDRussell May 19, 2026

Choose a reason for hiding this comment

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

are these public API changes covered in a proposal already, for WebViewProfileBinder and WebViewProfileBinder ?

FireModeAvailability had one, though now modified from it to remove suspend.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added the link for WebViewProfileBinder to the PR description.

@0nko 0nko force-pushed the feature/ondrej/fire-mode-webview-profiles branch from 6d5459e to ba1044a Compare May 25, 2026 11:54
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