Page Session
Manages the lifecycle, thread safety, state transitions, and ordered teardown of a single page session.
Rules:
Every path ends in close, including cancellation and exceptions.
Calling any method on a closed session throws ErrorCode.DETACHED.
Destroying the view is NEVER performed inside a WebView client callback.
Main thread operations are marshalled cleanly to the Looper.Main.
Constructors
Properties
The BrowserConfig this session was created with.
The live WebView, or throws ErrorCode.DETACHED if initialize has not run yet.
Where this session's counters are kept.
Scope tied to sessionJob; every session-owned coroutine should launch on this.
Coroutine scope owned by this session. Cancelling parentJob or calling close cancels this scope and triggers teardown.
Current lifecycle state.
Functions
Probes and returns actual capabilities for this session.
Throws ErrorCode.TARGET_CRASHED or ErrorCode.DETACHED if the session has been closed or destroyed.
Handles renderer termination (crash or OOM kill) from WebView callbacks. Discards the dead view, closes session state, and prevents host app crash.
Initializes the session on the main thread and creates the underlying WebView.
Returns true if the WebView render process for this session died or was killed by OS.
Returns snapshot of locally recorded session metrics.
Called by engines when a request is blocked, to tally the bytes that were saved.
Called by engines after a script runs, to accumulate evaluation count and time.
Called by engines after a navigation completes, to bump the local navigation counter.
Records a navigation this session refused under the SSRF rules.
Recovers a session after a renderer crash or termination. Recreates the underlying WebView and resets session health state.
Guarantees that an operation runs within the active session state.
Schedules ordered teardown off the current stack trace if triggered from a callback. Always posts to mainHandler so teardown never runs inside a WebView callback stack frame.