DEV Community

Anclum
Anclum

Posted on

Same call, three files: 1249x925, 780x493, and 324 bytes

Same call, three files: 1249x925, 780x493, and 324 bytes

The call is browser_take_screenshot with scale: "css" and nothing else. Three runs, two machines, three files:

Run OS Viewport before the call Bytes Dimensions
A Windows not set 51,691 1249×925
B Windows browser_resize 780 493 33,993 780×493
C Linux x86_64 session was already 780×493 33,669 780×493

Run A and run B are the same page, the same browser binary, and the same machine, 26 seconds apart (13:14:30 and 13:14:56 local). The only thing that changed between them is one call made before the screenshot. Run C is the same page on a different machine, at B's viewport, and it differs from B by 324 bytes.

That table is the whole point: the size of the file is decided before the screenshot call runs, and the screenshot call is not where you decide it.

The size is the session's, not the command's

browser_take_screenshot takes scale (css or device) and a filename. It does not take a width or a height, and it does not take a URL. Whatever viewport the session already has is what gets captured.

That viewport is created when the browser starts, from the window the session opens with. It is not a constant of the tool. Run C on Linux happened to be in a session that was already 780×493 — that is a fact about how that session started, not a property of the tool, and it is also why an earlier write-up in this account described 780×493 as the default. On this Windows machine a fresh session opened at 1249×925, which is why run A came out the way it did. The server reported Playwright, version 1.66.0-alpha-2026-11-18 on both machines. Two sessions, two sizes, one tool.

The practical consequence is that "what size will I get?" has no answer until you look at the session. If you need a specific size, say it out loud:

// order matters: set the viewport on the session, then navigate, then shoot
await client.callTool({ name: "browser_resize", arguments: { width: 780, height: 493 } });
await client.callTool({ name: "browser_navigate", arguments: { url: "https://example.com" } });
const shot = await client.callTool({ name: "browser_take_screenshot", arguments: { scale: "css" } });
Enter fullscreen mode Exit fullscreen mode

browser_resize ran while the page was still about:blank, and the navigation came after it. Run B is that order. If you never resize, you get run A. Resizing after the navigation was not tested.

What survives a move between systems, and what does not

At the same 780×493 viewport, Linux wrote 33,669 bytes and Windows wrote 33,993 bytes. The difference is 324 bytes:

  • 324 / 33,669 = 0.9623%
  • 324 / 33,993 = 0.9531%

Either way it is about 0.96%, which is close to one percent and nothing like a different image. What I can say is that both files report 780 x 493 in their PNG header and both were written from the same URL. What I cannot say is that the pixels are identical — I did not compare them pixel by pixel, and I would not expect them to be.

The two systems also did not run the same browser package. Linux had Chrome Headless Shell 159.0.8154.6 (playwright chromium-headless-shell v1255, a 125.7 MiB download). Windows needed Chrome for Testing 159.0.8154.6 (playwright chromium v1255); the install output reported 100% of 207.3 MiB for that package. So the 324 bytes sit on top of at least two differences — font rendering, which is the usual explanation for a sub-percent spread at equal dimensions, and two different builds of the same browser version. I measured the spread; I did not isolate which part of it comes from which cause.

The reusable sentence is: the viewport transfers between systems, the byte count does not. Treat 33,669 and 33,993 as two observations, not as a spec.

Zero is not success

The more expensive lesson on Windows came before any of the screenshots existed. With no browser installed, the same client ran two calls and got two errors:

NAV:  Error: Browser "chrome-for-testing" is not installed; expected executable at
     C:\Users\<user>\AppData\Local\ms-playwright\chromium-1255\chrome-win64\chrome.exe
SHOT: Error: Browser "chrome-for-testing" is not installed; expected executable at
     C:\Users\<user>\AppData\Local\ms-playwright\chromium-1255\chrome-win64\chrome.exe
DONE
EXIT=0
Enter fullscreen mode Exit fullscreen mode

Both tool calls returned isError: true. The client printed DONE anyway, and the process exit code was 0. In a pipeline that trusts exit codes, that run is green: the script finished, nothing threw, the shell was happy. In reality there is no PNG, and the two errors are the only evidence that anything went wrong.

The check that would have caught it is not clever: look for the file, then look at the file.

Three records worth keeping

For every screenshot I record three things, and none of them is a screenshot viewer:

  1. Byte count — from the filesystem, on the exact file the call reported. Run A: 51,691. Run B: 33,993. Run C: 33,669.
  2. Dimensions from the PNG header — the PNG IHDR chunk carries width and height as four-byte big-endian integers at bytes 16–19 and 20–23. That is what turned "1249×925" from an assumption into a measurement, without opening the image.
  3. The path the tool reported — [Screenshot of viewport](.playwright-mcp\page-2026-11-26T05-14-56-014Z.png). The filename proves which call wrote which file when two calls land in the same directory seconds apart.

On Linux I also had file, which prints PNG image data, 780 x 493, 8-bit/color RGB, non-interlaced — the same two numbers by a different route. Agreement between two independent readers of the header is what makes the dimension claim boring, which is the goal.

What these records do not answer is whether two screenshots show the same rendering. A 1249×925 capture and a 780×493 capture differ in layout because the viewport differs, so comparing them tells you nothing about the page. Compare only captures taken at the same viewport.

Boundaries

  • macOS was not run. One machine per system, one session per observation.
  • browser_resize(1280, 800) was never executed. Only 780,493 is measured. I can say the resize call works and that the screenshot honours it; I cannot say 1280×800 produces what the CLI produces at that size.
  • Byte counts are not stable across environments. Font rendering moves them by a fraction of a percent, and the two systems here did not even use the same browser package. Do not put 33,993 in a test assertion and expect it elsewhere.
  • Server-start viewport flags were not tested. Everything above sets the viewport per session, after the session exists.
  • One page. https://example.com, no dynamic content, no web fonts. A real page will move these numbers.

The reason to write this down is not the numbers. It is that three runs of one call produced three files, and only one of the three differences printed anything at all — the missing browser. The other two differences, 780×493 against 1249×925 and 324 bytes across systems, were silent. Silent differences are the ones that turn into "it worked on my machine".

The commands and both paths are written up on one page, with the same numbers and the same caveats: https://anclum.com/en/scene/automation/

Top comments (1)

Collapse
 
dosaygo profile image
DOSAYGO •

When you move Playwright MCP browser sessions off a local Windows machine onto a remote Linux environment, how do you handle interactive login, 2FA, or CAPTCHA prompts that need a live human view?