fix: keep background browser tabs screenshottable in headless mode (#201626) Root cause: extensions/browser/src/browser/pw-tools-core.interactions.content.ts:237 `capturePageScreenshot` never activates the tab, unlike the raw CDP screenshot path. In headless Chromium a background tab gets no new frame, so the Playwright capture never settles and the page's screenshot/emulation queue stays owned by it. Related: #165312 Thanks @titan550 for the detailed report, and @Oldrich333 for the deterministic background-tab reproduction. ## What Problem This Solves With a managed headless browser, once a page had been used through Playwright (any snapshot or action), a screenshot of a tab that was not the active one timed out. Every later screenshot on that tab then failed right away with "A previous screenshot or emulation action was cancelled but is still running", and only stopping the browser cleared it. Agents that share one browser across several tabs hit this often. ## User Impact Screenshots of background tabs in headless browsers work again, and a tab no longer gets stuck after one of them. Headed browsers keep their active tab, as before, so the same background-tab stall in a headed browser (the original report's Xvfb setup) is not changed by this PR; that needs a decision on whether captures may take focus in headed Chrome (#134400). ## Why This Change Was Made The raw CDP screenshot path already brings the tab to the front unless the browser is known to be headed. The Playwright path skipped that, so its capture waited for a frame that never came. Playwright captures now do the same activation inside the page's existing transition queue, using the same headless signal the route already passes to the raw path (also for labeled snapshot captures). The queue's ownership rule from #135315 is unchanged: an interrupted capture still holds the tab until Chromium finishes, it just no longer waits forever. ## Evidence Observed proof lines: [proof comment](https://github.com/openclaw/openclaw/pull/201626#issuecomment-7000314556) (base and candidate on a real Gateway with managed headless Chrome for Testing). - Linux, published 2026.11.5 (same screenshot code as main): background tab A times out after 5000 ms, the next call fails in 896 ms with "A previous screenshot or emulation action was cancelled but is still running"; 30 s later it still times out and then fails the same way. - Linux, packed build of this branch: the same five screenshots of tabs A and B all return images in 650-830 ms. - Control (macOS headless, one foreground tab, two screenshots): identical on base and candidate. - Headed Chrome on Xvfb (the original report's setup): unchanged on base and candidate, background tab A still times out and then reports the "still running" error, because headed browsers deliberately keep their active tab ([headed proof comment](https://github.com/openclaw/openclaw/pull/201626#issuecomment-7000527586)). - New regression cases fail on main and pass here: the capture activates the tab unless Chrome is headed, and the route passes the headed state to Playwright captures. Merge danger: two-way door, a revert fully undoes it; no state, config or contract change. Blast radius: Playwright screenshots on headless or unknown-mode Chrome profiles now bring the captured tab to the front, as raw CDP screenshots already did. Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Current
·
C2
·2026-11
fix: keep background browser tabs screenshottable in headless mode (#…
Find Your Interest
Current
·
C2
·2026-11





