Skip to content

fix(export): preserve full frames within the server screenshot budget - #458

Merged
kgoedecke merged 7 commits into
mainfrom
fix/export-pixel-budget
Nov 21, 2026
Merged

kgoedecke merged 7 commits into
mainfrom
fix/export-pixel-budget

Conversation

@kgoedecke

@kgoedecke kgoedecke commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

A full-frame PNG or JPG could lose its bottom rows on the server when the requested density exceeded the renderer’s 50 MP capture limit. A 1440 × 2560 frame at 4× lost 390 CSS pixels from the bottom.

Full-frame server exports now lower the density only when the screenshot would be cut short. Browser renders keep their previous scale. When the browser falls back to the server for a small layer on an oversized frame, it can request the layer directly at the selected density. The image URL, screenshot endpoint, download filename and MCP dimensions use the full-frame scale where appropriate.

Verified both full-frame HTTP routes against Chromium. The example produces a 5299 × 9421 PNG with the bottom marker visible at 3.68×, and the 64 × 64 layer at its foot exports at 256 × 256 when requested at 4×. Regression tests cover local downloads, layer downloads and clipboard copies, MCP metadata, and the render budget.

kgoedecke and others added 5 commits November 8, 2026 17:19
#456)

* fix(screenshot): recover from a wedged Chromium and bound every render

On 2026-11-05 prod's one shared headless Chromium stopped creating pages
from 17:41 UTC: its DevTools socket stayed open, so `connected` stayed
true, and every render (frame images, MCP screenshots, the resident's
checks, exports, imports) waited out puppeteer's 30s target timeout for
two hours until a manual restart. getBrowser only ever checked
`connected`, nothing bounded concurrent pages, and a stuck DevTools call
held its caller for puppeteer's default 180s.

server/renderBrowser.ts now owns the browser's lifecycle:

- a gate of RENDER_CONCURRENCY pages (default 4), background thumbnails
  capped at 2 and served after waiting agents, with a bounded, timed
  queue that refuses with RendererBusyError (HTTP 503 + Retry-After)
- opening a page has a 15s deadline; a browser that cannot open one is
  killed with its process group (a stalled graceful close no longer
  prevents the SIGKILL) and the open retried once on one shared
  replacement launch
- a render that fails like a browser failure runs a health probe outside
  the gate; a browser that fails it is killed and the render rerun once,
  a frame that is merely slow is not retried
- every page has a 120s lease, so a stuck caller cannot starve the gate
- browsers are recycled after 500 pages or an hour, drained first
- DevTools commands time out at 60s instead of 180s
- screenshots are capped at 50M device pixels (renderLimits.ts); the MCP
  tool says when it cropped
- GET /healthz/renderer reports kills, queue depth, lastOpenedAt and
  failed opens in a row for an uptime check

Builds on #399 (deadline, retry on a fresh launch) and
fixes its two open review findings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): address review on the render pool

- importPage gives its capture page back before opening the preview page,
  so view_website and import_webpage no longer wait on themselves when
  RENDER_CONCURRENCY=1.
- Tall renders keep the full frame height as the viewport (100vh, height
  media queries and bottom-fixed elements lay out as on the canvas); the
  pixel budget only bounds the captured clip.
- A page whose context will not close kills its browser instead of handing
  its slot to the next render while it may still be alive.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 8bfec4dffbf2f862cca00278bcf7a19516b9d38a)
…ser Run) (#458)

* feat(screenshot): render in a remote Chrome over CDP, e.g. Cloudflare Browser Run

REMOTE_BROWSER_URL (+ REMOTE_BROWSER_TOKEN as a Bearer header) swaps the
local Chromium launch for puppeteer.connect; the gate, deadlines, probe and
recycling from the render pool stay in front of it. A remote browser is
closed 30s after its last page, since providers bill open sessions, and one
whose close stalls is disconnected. Provider-neutral: Cloudflare, browserless
or our own renderer service are each just a URL.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): name a refused remote connection, and let PDF export run on a remote browser only

A provider refusing the CDP upgrade rejects with a ws ErrorEvent, not an
Error, so routes answered a bare 500; a 429 now surfaces as RendererBusyError
(503 + Retry-After) and anything else keeps its message. PDF availability
asked only for a local Chrome binary.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): let a remote browser fetch public resources itself

The pinned proxy in guardPublicPageRequests keeps a local browser off the
server's private network by fetching every resource in Node and handing the
body back over CDP. A remote browser is not on that network, and shipping
every body across the internet timed heavy website imports out (stripe.com,
doop.design). Off the network, public http(s) requests continue in the
browser; private addresses and other schemes are still refused. Closing a
remote page gets 15s, since a heavy import's teardown outlived 5s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(pdf): count a remote browser on a server without a local Chrome

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): fetch directly only from a remote browser declared isolated

Being remote does not mean being off our network: a self-hosted renderer
can sit beside private services, and continuing its requests would let an
imported page reach them through a hostname that resolves privately.
REMOTE_BROWSER_ISOLATED is the explicit declaration (a hosted provider such
as Cloudflare); without it a remote browser stays on the DNS-pinned proxy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit af873bed1d6d16ebe6da53f01d466cdcbaba03a2)
The frame replay bridge only reached iframe[data-doop-frame], so the
prototype player's screens (data-doop-proto-frame) stayed opaque
sandboxed documents and replayed blank.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit cebc050ac93202eddeb0b470f63be6fe93c1fc56)
search_logos' keyless fallback handed agents DuckDuckGo .ico URLs, which
sharp cannot decode. A small decoder now reads the icon's largest entry,
PNG or bitmap, with its transparency; the favicon is converted to PNG and
stored as a Doop asset (one per domain per process), so frames hold a plain
image on our own origin. When an open-source vector mark exists and the
only brand hit is a favicon, the vector marks come first and the favicon is
labelled as one, in both the MCP tool and the resident agent.

(cherry picked from commit b42dc426a05555e4a40f81eb452ba963f4c6cbbe, without
the Figma and Canva export paths, which OSS does not ship)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fitExportScale allowed 64 MP and never went below 2x, while the server
renderer cuts a screenshot at 50 MP, so a 1440x2560 frame at 4x (or a
tall frame at 2x) downloaded with its bottom silently missing. One
budget now serves both, and any scale comes down to fit it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Applies the renderer’s 50-million-pixel budget to export scales, including scales below 2x.

  • Raster exports lower oversized scales to keep the whole frame in the image.

Reviews (1) · Last reviewed commit: "fix(export): fit every export scale to t..." · Reviewed by Greptile

kgoedecke added a commit that referenced this pull request Nov 16, 2026
…ser Run) (#458)

* feat(screenshot): render in a remote Chrome over CDP, e.g. Cloudflare Browser Run

REMOTE_BROWSER_URL (+ REMOTE_BROWSER_TOKEN as a Bearer header) swaps the
local Chromium launch for puppeteer.connect; the gate, deadlines, probe and
recycling from the render pool stay in front of it. A remote browser is
closed 30s after its last page, since providers bill open sessions, and one
whose close stalls is disconnected. Provider-neutral: Cloudflare, browserless
or our own renderer service are each just a URL.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): name a refused remote connection, and let PDF export run on a remote browser only

A provider refusing the CDP upgrade rejects with a ws ErrorEvent, not an
Error, so routes answered a bare 500; a 429 now surfaces as RendererBusyError
(503 + Retry-After) and anything else keeps its message. PDF availability
asked only for a local Chrome binary.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): let a remote browser fetch public resources itself

The pinned proxy in guardPublicPageRequests keeps a local browser off the
server's private network by fetching every resource in Node and handing the
body back over CDP. A remote browser is not on that network, and shipping
every body across the internet timed heavy website imports out (stripe.com,
doop.design). Off the network, public http(s) requests continue in the
browser; private addresses and other schemes are still refused. Closing a
remote page gets 15s, since a heavy import's teardown outlived 5s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(pdf): count a remote browser on a server without a local Chrome

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(screenshot): fetch directly only from a remote browser declared isolated

Being remote does not mean being off our network: a self-hosted renderer
can sit beside private services, and continuing its requests would let an
imported page reach them through a hostname that resolves privately.
REMOTE_BROWSER_ISOLATED is the explicit declaration (a hosted provider such
as Cloudflare); without it a remote browser stays on the DNS-pinned proxy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
(cherry picked from commit af873bed1d6d16ebe6da53f01d466cdcbaba03a2)
(cherry picked from commit 9d62ccf)
@kgoedecke kgoedecke changed the title fix(export): fit every export scale to the renderer's pixel budget fix(export): preserve full frames within the server screenshot budget Nov 21, 2026
@kgoedecke
kgoedecke changed the base branch from sync/private-2026-11-08 to main November 21, 2026 10:18
@kgoedecke
kgoedecke merged commit 20d4e7d into main Nov 21, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant