Retry captureScreenshot after compositor-idle timeout
Reproduction
On headless Chrome 149 attached through CDP, Page.captureScreenshot can block for roughly 45–90 seconds when the compositor surface has gone idle while a live WebRTC audio track keeps the renderer alive. Navigation and Runtime.evaluate remain healthy. A static DOM plus WebRTC loopback reproduces after about 20 seconds of idleness; adding an rAF canvas animation makes the capture immediate. fromSurface: false did not avoid the stall.
The harness IPC screenshot request budget is 60 seconds, so the current capture_screenshot() raises _IPCResponseTimeout even though the browser session remains usable.
Proposed resilient recovery
On the first _IPCResponseTimeout from Page.captureScreenshot, issue a stateless compositor wake-up and retry once:
Page.startScreencastwith a low-quality JPEG- wait about 250 ms
Page.stopScreencast- retry the original
Page.captureScreenshotexactly once
This returned a screenshot in about 0.1 seconds after two independent reproductions. It does not alter viewport/emulation state. Avoid using Emulation.setDeviceMetricsOverride as a generic kick: zero/default values can silently overwrite an active DPR emulation override.
A local 0.1.13 patch using this bounded kick+retry is in use downstream until an upstream release includes an equivalent fix.
Environment
- browser-harness 0.1.13
- Headless Chrome 149.0.7827.54
- Linux
- CDP-attached browser session
Source: browser-use/browser-harness