Browser Use in-app browser screenshots capture the wrong region
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.422.21637 (2056)
What subscription do you have?
ChatGPT Pro 20x ($200)
What platform is your computer?
Darwin 25.4.0 arm64 arm
What issue are you seeing?
Browser Use screenshots in the Codex Desktop in-app browser capture the wrong region.
Page.captureScreenshot({ clip }) expects DIP coordinates, but Browser Use appears to pass CSS-pixel coordinates directly. Converting the clip rect to DIP fixed the issue locally.
Affected APIs observed:
tab.cua.get_visible_screenshot()
tab.playwright.screenshot({ fullPage: false })
tab.playwright.screenshot({ fullPage: true })
tab.playwright.screenshot({ clip })
What steps can reproduce the bug?
Ask Codex Desktop to use the in-app browser and take screenshots of a page, for example:
Use the in-app browser to open https://openai.com/codex/.
Then take:
1. a visible screenshot with tab.cua.get_visible_screenshot()
2. a visible screenshot with tab.playwright.screenshot({ fullPage: false })
3. a full-page screenshot with tab.playwright.screenshot({ fullPage: true })
4. a clipped screenshot with tab.playwright.screenshot({ clip: { x: 0, y: 0, width: 1000, height: 1000 } })
Show me the resulting images and their dimensions.
On the affected implementation, the visible screenshots capture a too-narrow region of the page. The explicit clipped screenshot also returns the wrong size: in my local repro, requesting 1000 x 1000 returned 634 x 634.
After applying a local patch that converts the clip rect to DIP with cssVisualViewport.zoom, the same prompt produced correct visible/full-page screenshots and the explicit clipped screenshot returned 1000 x 1000.
What is the expected behavior?
Screenshots should capture the requested region with correct bounds.
For visible screenshots:
tab.cua.get_visible_screenshot()
tab.playwright.screenshot({ fullPage: false })
the returned image should match the visible in-app browser viewport.
For full-page screenshots:
tab.playwright.screenshot({ fullPage: true })
the returned image should capture the page content with correct bounds.
For explicit clipped screenshots:
tab.playwright.screenshot({ clip: { x, y, width, height } })
the returned image should have the requested width and height, and should contain that requested page region.
Additional information
Environment
- Browser Use plugin:
0.1.0-alpha1 - Backend:
iab
Current implementation
The current code gets CSS-pixel values from Page.getLayoutMetrics() and passes them directly as the CDP screenshot clip rectangle. The logic looks like:
const { cssVisualViewport } = await cdp.call(tabId, "Page.getLayoutMetrics");
const scale = 1 / window.devicePixelRatio;
clip = {
x: cssVisualViewport.pageX,
y: cssVisualViewport.pageY,
width: cssVisualViewport.clientWidth,
height: cssVisualViewport.clientHeight,
scale,
};
await cdp.call(tabId, "Page.captureScreenshot", {
clip,
// other options...
});
Tested local fix
Keeping the existing output scale and multiplying the rectangle coordinates by cssVisualViewport.zoom fixed the captured region locally.
const scale = 1 / window.devicePixelRatio;
const zoom = cssVisualViewport?.zoom ?? 1;
clip = {
x: cssX * zoom,
y: cssY * zoom,
width: cssWidth * zoom,
height: cssHeight * zoom,
scale,
};
Applied to:
- visible viewport clip from
cssVisualViewport - full-page clip from
cssContentSize - explicit
tab.playwright.screenshot({ clip })
After patching browser-use/0.1.0-alpha1/scripts/browser-client.mjs, all screenshots captured the expected region locally.
CDP References
Page.captureScreenshot: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-captureScreenshotPage.Viewport: https://chromedevtools.github.io/devtools-protocol/tot/Page/#type-ViewportPage.getLayoutMetrics: https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-getLayoutMetricsPage.VisualViewport: https://chromedevtools.github.io/devtools-protocol/tot/Page/#type-VisualViewport- Note that the
zoomfield has the definition "Page zoom factor (CSS to device independent pixels ratio)."