Skip to content

P0 hardening: renderer crashes, popups, error pages, TV, incognito privacy - #13

Merged
GothwadTech merged 1 commit into
mainfrom
fix/p0-hardening
Nov 24, 2026
Merged

GothwadTech merged 1 commit into
mainfrom
fix/p0-hardening

Conversation

@GothwadTech

@GothwadTech GothwadTech commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the six production blockers from the code audit. No behaviour change for a healthy page.

# Blocker Fix
1 A renderer crash killed the app WebViewClient.onRenderProcessGone destroys the dead WebView, removes it from the pool, drops the tab and returns true. One tab dies instead of the process.
2 window.open() / target=_blank were dead setSupportMultipleWindows(true) + onCreateWindow: the popup WebView is created in the pool, handed to WebViewTransport, and the ViewModel adopts that exact tab id (adoptPopupTab).
3 Failed loads showed a blank page onReceivedError (main frame) and onReceivedSslError raise a PageError; a new overlay offers Try again and Close tab. SSL errors cancel the load — no bypass path.
4 No Android TV presence LEANBACK_LAUNCHER category, android:banner, android.software.leanback (not required) and optional touchscreen, plus a 320×180 banner generated from the official logo.
5 Incognito was not isolated Visited hosts are tracked per incognito tab and their cookies deleted when the last one closes; cache, form data and history cleared; FLAG_SECURE is set while an incognito tab is open, so it stays out of screenshots and the Recents thumbnail.
6 Cleartext policy was implicit Explicit network_security_config.xml that documents why a browser cannot block http:// outright, and what protects the user instead: HTTPS-first on by default, no certificate bypass, insecure warning in the omnibox.

Files

  • browser/WebViewPool.kt — new callbacks (onPopupTabCreated, onPageError, onRendererGone), onCreateWindow, error/SSL/renderer handlers, incognito host tracking + clearIncognitoData()
  • viewmodel/BrowserViewModel.kt — PageError state, adoptPopupTab, onPageError, onRendererGone
  • ui/BrowserApp.kt — new callbacks, PageErrorOverlay, FLAG_SECURE effect, incognito wipe on last close
  • AndroidManifest.xml, res/xml/network_security_config.xml, res/drawable-nodpi/tv_banner.png

Honest limitations

  • WebView has one process-wide cookie jar, so true per-tab incognito isolation is impossible; the fix is refuse-cookies + wipe-on-exit, which is what other WebView browsers do.
  • onReceivedHttpError (a 404/500 the server itself renders) is deliberately left alone — the site's own error page is better than ours.
  • D-pad navigation relies on Compose focus traversal and WebView's native focus handling; the TV banner and launcher entry are what make the app reachable at all. Dedicated remote polish is a separate change.

Checks

Compiles via the PR's own Quality Gate & Tests run (assembleDebug + lint + unit tests).

Summary by CodeRabbit

  • New Features
    • The app can now appear in Android TV launchers and supports TV navigation.
    • Links that open new windows can now open in popup tabs.
    • Page load and certificate errors display an on-screen message with options to retry or close the tab.
  • Bug Fixes
    • Crashed or terminated pages are handled with a notification, and the affected tab is closed.
    • Incognito tabs now prevent screen capture; closing the last incognito tab clears related browsing data.

…cognito privacy

Six production blockers found in the audit:

1. Renderer crash killed the app — WebViewClient.onRenderProcessGone now destroys
   the dead WebView, drops the tab and returns true, so a crashing page costs one
   tab instead of the whole app.
2. window.open()/target=_blank were dead ends — supportMultipleWindows is on and
   onCreateWindow creates the popup WebView in the pool, hands it to the
   WebViewTransport and asks the ViewModel to adopt that exact tab.
3. Failed loads left a blank screen — onReceivedError and onReceivedSslError now
   surface a PageError overlay with Try again / Close tab. Certificate errors are
   cancelled; there is no bypass.
4. No TV presence — LEANBACK_LAUNCHER category, android:banner, leanback and
   optional-touchscreen features, plus a 320x180 banner generated from the logo.
5. Incognito leaked — visited hosts are tracked and their cookies removed when the
   last incognito tab closes, cache/form data/history cleared, and FLAG_SECURE is
   set while an incognito tab is open so it stays out of screenshots and Recents.
6. Cleartext policy was implicit — an explicit network_security_config documents
   why a browser cannot block http:// outright and what protects the user instead
   (HTTPS-first, no certificate bypass, insecure indicator in the omnibox).
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Changes: Browser platform and WebView behavior

Layer / File(s) Summary
Platform and network configuration
app/src/main/AndroidManifest.xml, app/src/main/res/xml/network_security_config.xml
The manifest declares optional leanback and touchscreen features, adds the TV banner and launcher category, and references a network security configuration. The configuration permits cleartext traffic and trusts system certificates.
WebView popup, error, and incognito handling
app/src/main/java/com/bansify/browser/browser/WebViewPool.kt
WebViewPool creates and registers popup WebViews, reports main-frame and SSL errors, and handles renderer termination. It records hosts visited in incognito tabs and clears matching cookies, cache, form data, and history when requested.
Tab state and browser UI
app/src/main/java/com/bansify/browser/viewmodel/BrowserViewModel.kt, app/src/main/java/com/bansify/browser/ui/BrowserApp.kt
BrowserViewModel adopts popup tabs, stores page-error state, and handles renderer termination. BrowserApp forwards WebView events, displays retry and close actions for active-tab errors, and applies FLAG_SECURE while incognito tabs are open. It clears incognito data when the last incognito tab closes.

Change: Bug fix

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@GothwadTech
GothwadTech merged commit f81dc5c into main Nov 24, 2026
4 of 5 checks passed
@GothwadTech
GothwadTech deleted the fix/p0-hardening branch November 24, 2026 04:28
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.

1 participant