fix(screenshot): fall back to CDP capture when captureVisibleTab fails (#83)

chrome.tabs.captureVisibleTab reads back the window surface, which fails
outright on some Windows/Chrome combinations (Chromium
FAILURE_REASON_READBACK_FAILED: "Failed to capture tab: image readback
failed"), leaving full-tab screenshots without any working path.

Capture the full tab via CDP Page.captureScreenshot (fromSurface) when
the visible-tab capture rejects; the CDP path goes through the
renderer BeginFrame pipeline instead of the surface readback. When both
paths fail, return cdp_failed with data.reason=screenshot_capture_failed
carrying both underlying messages, and render a CLI hint that points at
the browser-side readback cause.

Refs #71
This commit is contained in:
BB-fat
2026-08-12 22:10:09 +08:00
committed by GitHub
parent 78c2719718
commit f81a1e7796
4 changed files with 157 additions and 23 deletions
+2 -1
View File
@@ -31,7 +31,8 @@ export type RpcErrorReason =
| "single_select_value_count"
| "tab_not_active"
| "restricted_tab_url"
| "borrow_conflict";
| "borrow_conflict"
| "screenshot_capture_failed";
export interface RpcErrorData {
reason?: RpcErrorReason;