Repository navigation
fix(mobile): keep Attach Photos working while desktop requests are stalled - #36922
Conversation
Desktop RPCs and on-device native verbs shared the bridge's 64 in-flight request slots on both page and shell. Unanswered desktop calls could hold all of them, refusing native.media.pick and native.media.release; refused releases stranded staged handles until expiry, so later picks hit native_media_handle_cap. Desktop calls now stop at 60 so native verbs always have the last 4.
|
No actionable comments were generated in the recent review.
|
ELI5
On the phone, the web page talks to the app through a pipe that can hold 64 open requests. Requests to the desktop and requests for things the phone does itself, like opening the photo picker, shared those 64 slots. If the desktop stopped answering for a while, its requests could fill all 64, and tapping Attach Photos did nothing. Now the desktop can only use 60 of them, so the last 4 are always free for the phone's own actions.
What Changed
native.media.pickwas refused before the picker opened (Mobile native actions are starved by outstanding desktop bridge requests #36568). A refusednative.media.releasewas only logged by the page, so each refusal left a staged photo handle open. After eight of those, every later pick failed withnative_media_handle_capuntil the 5-minute expiry, even once the desktop answered again (Failed staged-media releases strand all attachment slots after transport recovery #36573).native.*verbs are admitted up to the existing 64. The total bound is unchanged.bridgePendingRequestCap(isNative)inbridge-caps.ts, next toBRIDGE_MAX_PENDING_REQUESTS. The page (BridgeRpcClient.sendRequest) and the shell (BridgeHostRequests.open) both admit requests through it. The shell's count already includes desktop calls that outlive a closed page, so a replacement page also finds the reserve free.Why
The registry never fails a release on its own:
MediaHandleRegistry.releasedeletes the handle before a best-effort file delete. A release therefore fails only when the bridge refuses the request, and in practice that means the shared cap. Reserving slots fixes the starvation and the stranded handles at the one decision that caused both.Alternatives considered:
Mixed versions:
#36571 (the page keeping a retired
orcaBridge) is left out on purpose, because shipped shells can't replace the channel inside a live document:orcaBridgewithconfigurable:false, writable:falseat document start.addWebMessageListeneronly right beforeloadUrl, and Chromium injects the object into the next document only.Linked Issue
Fixes #36568
Fixes #36573
Visual Proof
N/A. Nothing on screen changes. The failure only appears after 60 or more desktop calls stall, so it was reproduced in the real page↔shell bridge harness, which runs the serialized page client, the shell host, and the real native media server and registry. On main, the new test fails at the first pick with
BridgeClientCapExceededError: over 64 requests in flight. A variant that lets picks through but takes the slot before each release fails on round 9 withnative_media_handle_cap. With this change both pass.Testing
bridge-host-media-verbs.test.ts: with every desktop slot filled before each step, nine pick → read → release rounds succeed and leave no live handles. This fails on main.bridge-host-native-verbs.test.ts: an older page sends 64 desktop requests. The new shell admits 60 and still serves a native verb. This fails on main.Existing cap tests are now pinned to the desktop cap (
BRIDGE_MAX_PENDING_DESKTOP_REQUESTS). The probe that fills slots until refused is now shared through the port-pair harness.Ran the focused bridge, media, dictation and native-media tests, the RPC recording goldens (2334 tests), the changed-file quality and React Doctor checks, oxlint and oxfmt. I didn't run anything on a device. The change is shared TS that runs the same way on iOS and Android.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)