Skip to content

fix(webview): persist only settled page state to fix stale-URL black screen (#333)#335

Open
theoden8 wants to merge 2 commits into
masterfrom
claude/fix-issue-333-CXCYl
Open

fix(webview): persist only settled page state to fix stale-URL black screen (#333)#335
theoden8 wants to merge 2 commits into
masterfrom
claude/fix-issue-333-CXCYl

Conversation

@theoden8

@theoden8 theoden8 commented May 13, 2026

Copy link
Copy Markdown
Owner

The renderer-death recovery and Android paint-nudge fixes that originally
opened this branch landed separately in #375. The two commits remaining
here address the other half of #333 — a transient URL persisted
mid-redirect that boots to about:blank on the next launch:

  1. Settle-gated persistence. Caching HTML and committing currentUrl on
    every onLoadStop captured transient redirect states (Cloudflare
    js_challenge callbacks, mid-redirect interstitials). On next launch the
    WebView booted at the stale single-use token URL, the live-reload
    one-shot bounced to about:blank, and the user sat on a black page until
    manually going home. New WebViewModel.lastSettledUrl tracks only URLs
    the page held for WebViewConfig.settleDelay (3s) without a new
    onLoadStart; the cache save and onPageSettled fire from the same settle
    point so the (URL, HTML) pair stays coherent. Cancelled by any
    onLoadStart, rescheduled by SPA pushState, with epoch + navigationGen
    checks to bail an in-flight settle body if the page moves under it.
    onHtmlLoaded is awaited so the cache file lands before lastSettledUrl
    advances.

  2. Cancel pending settle on dispose. A settle Timer armed ~1s before a
    site is unloaded could still fire and commit transient state for a site
    the user already switched away from. Drain the Timer via
    WebViewConfig.onSettleHandlerReady in disposeWebView before the
    controller is nulled.

Fixes #333.

@theoden8 theoden8 force-pushed the claude/fix-issue-333-CXCYl branch 2 times, most recently from aa7c1f8 to ed8cc32 Compare May 17, 2026 13:12
@theoden8 theoden8 force-pushed the claude/fix-issue-333-CXCYl branch 2 times, most recently from d7eb198 to 7c14948 Compare May 26, 2026 20:32
claude added 2 commits May 27, 2026 10:01
Caching HTML and committing currentUrl on every onLoadStop captured
intermediate redirect states — Cloudflare js_challenge callbacks,
mid-redirect interstitials — and persisted them as the canonical
state. On next launch the WebView booted at the stale single-use
token URL, the live-reload one-shot bounced to about:blank, and the
user sat on a black page until manually going home.

New WebViewModel.lastSettledUrl tracks only URLs the page held for
WebViewConfig.settleDelay (3s) without a new onLoadStart. The Timer
that fires the cache save now also fires onPageSettled, so both
writes share a single settle point and stay coherent. Cancelled by
any onLoadStart; rescheduled by SPA pushState; epoch+navigationGen
checks bail an in-flight settle body if the page moves under it.
toJson persists lastSettledUrl under the existing currentUrl key.

onHtmlLoaded is now awaited so the cache file lands before
lastSettledUrl advances, ordering the writes against a mid-settle
crash.

Fixes #333.
A settle Timer scheduled by an onLoadStop fired ~1s before the site is
unloaded could still fire after disposeWebView() and commit transient
state (cached HTML / lastSettledUrl) for a site the user already
switched away from. Wire the closure-local cancelPendingSettle out via
WebViewConfig.onSettleHandlerReady and drain it in disposeWebView
before the controller is nulled. For #333.
@theoden8 theoden8 force-pushed the claude/fix-issue-333-CXCYl branch from 7c14948 to aebcf37 Compare May 27, 2026 09:01
@theoden8 theoden8 changed the title fix(webview): recover from renderer death on resume fix(webview): persist only settled page state to fix stale-URL black screen (#333) May 27, 2026
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.

Black screen after switching foreground app

2 participants