mirror of
https://github.com/cylonid/NativeAlphaForAndroid.git
synced 2026-11-05 00:47:30 +00:00
[PR #233] Keep the page across process death #234
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
cylonid/NativeAlphaForAndroid#234
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cylonid/NativeAlphaForAndroid/pull/233
Author: @dkodr
Created: 9/11/2026
Status: 🔄 Open
Base:
dev← Head:feat/webview-state📝 Commits (2)
a51f21cKeep the page across process death5c08ce2Enable the back-forward cache📊 Changes
2 files changed (+22 additions, -5 deletions)
View changed files
📝
app/build.gradle(+1 -1)📝
app/src/main/java/com/cylonid/nativealpha/WebViewActivity.java(+21 -4)📄 Description
WebViewActivitysaves no state, so when Android reclaims the process the activitycomes back on the start URL with the scroll position, open view and form contents
gone. Cookies live on disk, so it was never a logout — but every reclaim throws the
user back to the top of the app.
Saving
Through
WebViewCompat.saveStaterather than the frameworkWebView.saveState.The 1MB
savedInstanceStatebudget is shared by the whole process, and web appswithout sandboxing all live in the main one, so several open web apps can exceed it
together and crash with
TransactionTooLargeException. The Jetpack call takes a bytebudget and drops the oldest history entries to fit, without touching the live history,
so backward navigation stays intact. Forward entries are dropped as well, since there
is no forward button in the UI.
Only saves where the WebView reports
SAVE_STATE. Falling back to the framework callwould reintroduce exactly the crash the budget exists to prevent, so older WebViews
keep today's behaviour instead — no restore, but no new failure mode either.
The second commit turns on the back-forward cache, so going back inside a web app
restores the previous page from memory instead of re-running the load.
androidx.webkitgoes 1.13.0 → 1.17.0 for both. It needsminCompileSdk33, which islower than the 34 required by 1.13.0, so this is independent of the targetSdk work
in #231 and applies to
devas it stands.Testing
On a Pixel running Android 17 (API 37, WebView 151), killing the backgrounded process
with
am killto reproduce what the system does under memory pressure:at the top.
restored, no
TransactionTooLargeException, no crash in logcat. This is the casethe byte budget exists for.
stays hidden until it is answered, so the biometric path is unaffected.
Not verified: that the back-forward cache actually shortens back navigation. Enabling
the flag follows the documented API, but I could not measure the difference without
instrumenting WebView's network activity, so treat that commit as untested rather than
proven.
One thing I noticed while testing and did not touch:
setupWebView()runsunconditionally after the biometric branch in
onCreate, so a protected web appissues its network request before the prompt is answered. The content is not shown —
the view is hidden — so this is not a visual leak, and it predates this change. Happy
to fix it separately if you want.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.