状态:实现中 适用范围:Desktop
desktop-continuous的 Browser / Browser Use<webview>guest。 不适用:手机web-remote-replayable的独立恢复语义、relay/main 中的 session/stream 业务状态。
工单 ZCT-2092076135526567936 的 v3.9.1 构建中,连续 Playwright/CDP 自动化期间出现
ZCode 主进程 native access violation。崩溃前日志同时出现:
detachGuest cdp message cleanup failed ... Object has been destroyed
detachGuest cdp still attached on destroyed guest ...
这表明 guest WebContents 已经销毁,但 native DevTools session 尚未主动 detach;在途 CDP 通知随后
访问已析构的 client_,触发 Electron/Chromium 侧 UAF。destroyed 事件到达后再调用
debugger.detach() 已经太晚,不能作为安全兜底。
<webview>。tabId、guestId、guestGeneration、teardown reason、pending CDP 数量和结果,便于和 minidump 关联。web-remote-replayable 的 snapshot/queue 恢复语义引入桌面 continuous 主链路。destroyed 之后尝试“补救” native detach;该事件只用于收尾和异常打点。attached(generation=N)
|
| acquire CDP lease / pendingCommands++
v
command dispatch
|
+-----------------------------+
| |
v v
beginGuestTeardown(reason) command settled
|
├─ state = detaching
├─ reject new command dispatch
├─ abort tab-scoped running requests
├─ wait pending commands to settle (bounded)
├─ debugger.detach() and confirm detached
└─ resolve detached ACK
|
v
renderer replaces/unmounts <webview>
|
v
destroyed → cleanup only
同一 tab 的 teardown 必须 single-flight;旧 guest 的 generation 与新 guest 的 generation 不得复用。
BrowserGuestManager 为每个 ManagedTab 增加 teardown 状态、generation、teardown promise 和
pending CDP 计数。所有以下入口统一调用 beginGuestTeardown:
render-process-gone<webview> 前的显式 ACKdetachGuest 只负责状态清理;若它观察到 destroyed + cdpAttached,必须保留严重异常记录,不能将其
视为一次成功的 native detach。
toControlledView().cdp.send() 不得直接调用 guest.debugger.sendCommand()。必须:
UnifiedBrowserView 的任何可能导致 <webview> 消失的状态变化都必须等待:
renderer request replacement
→ main beginGuestTeardown
→ main confirms debugger.detach
→ detached=true ACK
→ setWebviewGeneration / unmount
ACK 失败时不得递增 webviewGeneration,不得直接卸载旧节点。
沿用 2026-08-23-browser-guest-scope-recovery-spec.md:tab 冻结 owner scope,attach 返回 typed result,
scope mismatch 使用单飞、有界 rebind;拒绝的 incoming guest 必须清理,避免 orphan WebContents 参与后续
CDP 生命周期。
stale_guest 或 backend_unavailable,不调用 debugger。debugger.detach()。destroyed + cdpAttached 被标记为异常,不被记录为正常 detach。cdp still attached on destroyed guest。BrowserGuestManager 的 lifecycle/lease/teardown 单测。pnpm typecheck、pnpm lint 后再进入发布验证。