Skip to content

chromium: Fail clearData explicitly instead of faking success - #2060

Open
NAME-ASHWANIYADAV wants to merge 1 commit into
Igalia:mainfrom
NAME-ASHWANIYADAV:fix/chromium-cleardata-honest-failure
Open

chromium: Fail clearData explicitly instead of faking success#2060
NAME-ASHWANIYADAV wants to merge 1 commit into
Igalia:mainfrom
NAME-ASHWANIYADAV:fix/chromium-cleardata-honest-failure

Conversation

@NAME-ASHWANIYADAV

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #2061

What

Two coordinated changes:

  • The Chromium RuntimeImpl.clearData() stub now returns WResult.fromException(new UnsupportedOperationException(...)) instead of an already-completed success. The TODO stays to signal that real clearing against the Chromium engine is a follow-up.
  • SessionStore.clearCache() now uses the two-listener then(valueListener, exceptionListener) overload: on failure it logs the error and still recreates the suspended sessions.

Why

The stub returned WResult.fromValue(null), so callers took their success path with nothing cleared. The user-facing path is Settings → Privacy → "clear cookies and site data" / "clear web content" (PrivacyOptionsView.java:74-83) → SessionStore.clearCache(). On Chromium the sessions suspend and reload, so the action looks like it worked - while cookies, site data and caches are untouched. The Gecko backend really clears (gecko/RuntimeImpl.java:91-92).

Failing the result alone - the way capturePixels was handled in #2025 - would have regressed this path: clearCache() suspends every session before calling clearData(), and recreateSession() lived only inside .then() with no .exceptionally(). An honest failure would have left every session suspended forever. That is why the caller changes in the same PR: with the error branch added, sessions are recreated on both outcomes.

Net behavior:

  • Chromium: sessions still suspend and recreate exactly as before; the result now reports the truth and the failure is logged instead of silently faked.
  • Gecko: the success path is unchanged; a real clearData failure is now logged and no longer strands suspended sessions (previously an unhandled rejection).

Follow-up (out of scope)

Implementing clearData for real against Chromium's BrowsingDataRemover, mapping WRuntime.ClearFlags onto its data-type mask.

Testing

  • Builds: ./gradlew assembleNoapiArm64GeckoGenericDebug
  • Existing unit tests pass: ./gradlew testNoapiArm64GeckoGenericDebugUnitTest

@NAME-ASHWANIYADAV NAME-ASHWANIYADAV changed the title Chromium clearData reports success without clearing anything chromium: Fail clearData explicitly instead of faking success Aug 28, 2026
@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

@svillar PTAL !!

session.recreateSession();
}
return null;
}, throwable -> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

instead of repeating the for loop can we do instead

whenComplete((aVoid, throwable) -> {
            if (throwable != null) {
                Log.e(LOGTAG, "Failed to clear browsing data", throwable);
            }

            for (Session session : activeSession) {
                session.recreateSession();
            }

The Chromium clearData stub returned a completed WResult while
clearing nothing, so clearing browsing data reported success. Add
WResult.whenComplete so SessionStore.clearCache logs the failure and
still recreates the suspended sessions.

Fixes Igalia#2061
@NAME-ASHWANIYADAV
NAME-ASHWANIYADAV force-pushed the fix/chromium-cleardata-honest-failure branch from a9eff6b to 2bd3d6d Compare September 1, 2026 16:44
@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

@svillar will appreciate a re-review !!

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor Author

One note: WResult didn't have whenComplete, so I added it as a default method mirroring CompletableFuture.whenComplete (built on the existing two-listener then, so both backends get it for free), and clearCache now uses exactly the shape you suggested. Also rebased on main and added the Fixes line to the commit

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.

Chromium clearData reports success without clearing anything

2 participants