Skip to content

android: reliable offline startup (#854) - #1693

Open
Suncadgeek wants to merge 2 commits into
pulsejet:masterfrom
Suncadgeek:offline-boot
Open

android: reliable offline startup (#854)#1693
Suncadgeek wants to merge 2 commits into
pulsejet:masterfrom
Suncadgeek:offline-boot

Conversation

@Suncadgeek

Copy link
Copy Markdown

This is the native half of #854. Today, launching the app without a working connection shows the raw Chromium error page (or hangs on a blank screen when requests stall instead of failing, which is what happens behind an always-on VPN), and the user has no way out but to retry manually.

With this change:

  • When the main frame fails to load and no cached copy is available, a friendly offline page is shown (same style as the welcome page) with a retry button, and the app reloads automatically as soon as connectivity returns. Reloads are driven both by the network callbacks on the native side (including a check for the VALIDATED capability, since onAvailable can fire before the network is actually usable) and by a periodic retry from the page itself.

  • A ServiceWorkerClient is registered mirroring the 127.0.0.1 interception of the WebViewClient. Requests going through a service worker bypass the WebViewClient, so without this the local photo APIs break as soon as the service worker controls the page.

  • The timeline is soft-refreshed when a validated network returns after a loss. The web app cannot rely on the online event for this: behind an always-on VPN the browser never observes the network going away.

  • A one-shot in-page reload is issued after an offline recovery. We observed pages that commit in a fresh renderer process on this path ending up never painted (Vanadium WebView on GrapheneOS, reproducible on unmodified master); an in-page reload in the same process reliably repaints.

  • checkCredentialsAndVersion now documents that parsing the body before the 401 check is what protects stored credentials from being wiped by captive portals.

Tested on a Pixel 7 (Android 16, GrapheneOS): airplane-mode cold start with and without caches, automatic recovery when connectivity returns, login flow, video playback and local photos unaffected. Works best together with the web-side changes in the companion PR, but is independently useful.

When the app is launched without connectivity and no cached copy is
available, show a friendly offline page instead of the raw Chromium
error page, and reload automatically when the connection returns
(network callbacks on the native side, online event and periodic
retry from the page itself).

The page is served from the app origin with loadDataWithBaseURL and
an in-page reload is issued once after recovery: a page that commits
in a fresh renderer process on the offline path can otherwise end up
never painted (observed with the Vanadium WebView; reproducible on
unmodified master).

Also register a ServiceWorkerClient mirroring the 127.0.0.1 native
API interception, since requests going through a service worker
bypass the WebViewClient.
The web app cannot rely on the online event to refresh after a
network loss: behind an always-on VPN the browser never observes the
network going away. The native side does know, so soft-refresh the
timeline when a validated network returns after a loss.
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