Repository navigation
Conversation
A shell screen that opens a new WebView (host page to session, the New Workspace overlay) used to build it, load the document and run 1.36 MB of entry code after the tap. Now, one second after a shell page paints and while its screen is focused in a foreground app, the screen asks the native pool to boot one page for its host from the same generation. The next screen that opens that generation takes the parked page's session id and adopts it, so only the route's own code and the first paint are left. - Feature-detected: on a binary without the pool OrcaMobileWebShellSpares is null, the runtime has no spares, and every open mints its own id and builds its own WebView as before. - Skipped when the page owns the host area: its screens open inside it. - A spare booted from a generation is dropped when that generation is deleted (download commit, delete-and-refetch) and when its host is removed. A remount always mints a fresh id. - After building the bridge host, the hook asks the view to replay the adopted page's ready, in case it arrived before the host existed. Co-Authored-By: Claude <[email protected]>
# Conflicts: # mobile/src/mobile-web-shell/mobile-web-shell-session-effects.test.ts # mobile/src/mobile-web-shell/use-mobile-web-shell-bridge.ts # mobile/src/mobile-web-shell/use-mobile-web-shell-session.test.ts # mobile/src/mobile-web-shell/use-mobile-web-shell-session.ts # mobile/src/transport/host-removal-lifecycle.test.ts
This was referenced Nov 8, 2026
AmoabaKelvin
added a commit
that referenced
this pull request
Nov 9, 2026
While native Home is on screen, boot one page document for the most recently connected host with a cached build, parked invisibly in the window. Opening a page from that build adopts it instead of building a WebView, which removes the WebView start and script parse from the tap. The spare is dropped when Home is left without a claim (2 s grace), on background, memory pressure, its own failure and before the cache deletes its files. It is never kept beside a shown page, and only phones with more than 3 GiB of RAM (4 GB phones) get one. A parked page is told to stop asking for init; the adopting view answers the ready it sent. Builds on Jinwoo's spare pool and replay work in #32203 and #32204. Co-authored-by: Jinwoo-H <[email protected]>
AmoabaKelvin
added a commit
that referenced
this pull request
Nov 9, 2026
…skips the WebView start (#40018) * perf(mobile): answer a page's ready that arrived before its bridge host A page's ready can reach the shell before the screen has built its bridge host (the host waits on the client and the host profile read). It used to be dropped, so init waited for the page's next retry, up to 2 s later. Keep the latest ready per session and answer it once the host exists. * perf(mobile): keep one prewarmed page document while Home is shown While native Home is on screen, boot one page document for the most recently connected host with a cached build, parked invisibly in the window. Opening a page from that build adopts it instead of building a WebView, which removes the WebView start and script parse from the tap. The spare is dropped when Home is left without a claim (2 s grace), on background, memory pressure, its own failure and before the cache deletes its files. It is never kept beside a shown page, and only phones with more than 3 GiB of RAM (4 GB phones) get one. A parked page is told to stop asking for init; the adopting view answers the ready it sent. Builds on Jinwoo's spare pool and replay work in #32203 and #32204. Co-authored-by: Jinwoo-H <[email protected]> * fix(mobile): unregister the shell's memory callbacks from the context that registered them --------- Co-authored-by: Jinwoo-H <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a shell screen has painted and is idle, the phone boots the next page in the background, so the next host to session open reuses it instead of starting a new WebView. On iOS this removes the per-view web process start.
useSparePageRefillprepares a spare 1 s after paint while the screen is focused and the app is active, and only when the screen shows the host's current generation (a screen left behind by an update would boot from a deleted tree and evict the good spare). It skips screens whose page owns the host area.OrcaMobileWebShellSparesis null and every path above is skipped.Numbers
Host screen to session screen, tap to painted, median, release builds, interleaved per cycle, base vs spare.
On Android, tap to page init drops from 451 ms to 204 ms. On iOS, the base spends about 945 ms between loading the URL and the page starting, which is the new WebView's web process starting; the spare has already paid it. First-open noise between runs is about 100 to 200 ms.
Galaxy S24
Pending: base vs spare on a Galaxy S24, interleaved, at least 8 cycles per arm, same 4 s wait. Results will be added here.
Method
Release builds of this stack and of its base, with the start-up timing marks, against a source-built desktop serving the same page bundle. Each cycle opens the host screen, waits 4 s, taps into a session and reads tap, init and painted marks from the log; the arms alternate every cycle. The spare is not used by the first open after launch, only by the next screen, which is what the refill targets.
Simulator vs device
Emulator and simulator numbers show direction, not size. The iOS gain is large because the simulator's web process start is slow; on a device the start is cheaper, and the spare's memory cost (one extra WebView while idle) matters more. The Galaxy S24 run above, once done, will size Android on a device; iOS device memory is on the release checklist.
Checks
Mobile vitest, typecheck and lint pass. Release builds, device-check flows on the Android emulator (API 36) and the iOS 26.5 and 18.1 simulators: first open, host to session, New Workspace overlay, pop to an existing screen (#32110), renderer kill then remount, background then foreground, new page generation from a desktop update, host removal and re-pair. On iOS, taps where the parked spare sits under the host page reach the host page.
On the iOS 18.1 simulator the spare's presence was confirmed from the window's view tree: with this stack the window holds the parked WKWebView at index 0 with user interaction off plus the host page's WKWebView; without it, only the host page's.
After review fixes, on test-only builds that log the pool (not committed): an update followed by a return to a screen on the old generation boots nothing from the old tree, and the next session adopts the spare booted from the new one (Android emulator; on iOS 26.5 the shell's controls never refocus an older shell screen, so there the spare booted after the update was checked to be adopted by the next host open). A spare claimed but not yet adopted is destroyed by host removal (Android) and by backgrounding (iOS 26.5), and the screen comes back live.
Compat
New JS on a binary without the native pool takes today's path: it never calls the pool and mints session ids as before. Checked by running this JS on main's native code through every flow above. The page bundle is unchanged.