mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* 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 <73622457+Jinwoo-H@users.noreply.github.com> * fix(mobile): unregister the shell's memory callbacks from the context that registered them --------- Co-authored-by: Jinwoo-H <73622457+Jinwoo-H@users.noreply.github.com>
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
import { readBridgeClientMessage } from './bridge/bridge-envelope'
|
|
import { frameWithoutHostLine } from './shell-bridge-log-lines'
|
|
import { recordShellLifecycleLine } from './shell-lifecycle-line-recorder'
|
|
|
|
export type FrameWithoutHostFacts = { hostId: string; clientReady: boolean; snapshotReady: boolean }
|
|
|
|
export type PageFramesWithoutHost = {
|
|
/** A frame no host serves yet; `facts` is null when a retired session's host is still mounted. */
|
|
receive: (sessionId: string, json: string, facts: FrameWithoutHostFacts | null) => void
|
|
/** Hands the page's latest ready for this session to the host just built for it, once. */
|
|
replayReady: (sessionId: string, host: { receive: (json: string) => void }) => void
|
|
}
|
|
|
|
// Keep the ready instead of dropping it, so init does not wait on the page's 50 ms to 2 s backoff.
|
|
export function createPageFramesWithoutHost(): PageFramesWithoutHost {
|
|
let loggedSessionId: string | null = null
|
|
let ready: { sessionId: string; json: string } | null = null
|
|
return {
|
|
receive: (sessionId, json, facts) => {
|
|
if (facts !== null && loggedSessionId !== sessionId) {
|
|
loggedSessionId = sessionId
|
|
recordShellLifecycleLine(facts.hostId, frameWithoutHostLine(facts))
|
|
}
|
|
const read = readBridgeClientMessage(json)
|
|
if (read.ok && read.message.type === 'ready') {
|
|
ready = { sessionId, json }
|
|
} else if (read.ok && read.message.type === 'close') {
|
|
// The document that asked is gone, so its ready must not be answered.
|
|
ready = null
|
|
}
|
|
},
|
|
replayReady: (sessionId, host) => {
|
|
const kept = ready
|
|
ready = null
|
|
if (kept?.sessionId === sessionId) {
|
|
host.receive(kept.json)
|
|
}
|
|
}
|
|
}
|
|
}
|