Skip to content

feat(page): reveal dynamic pages before the capture - #8

Merged
jaspermayone merged 4 commits into
mainfrom
feature-dynamic-pages
Nov 9, 2026
Merged

jaspermayone merged 4 commits into
mainfrom
feature-dynamic-pages

Conversation

@jaspermayone

Copy link
Copy Markdown
Member

What

Stash captured interceptingoutliers.com as 10,000px of blank cream: the site reveals each section as the reader scrolls, so the page as first loaded is empty below the fold. The page capturer now reveals the page before it writes anything:

  1. Asks Chromium for prefers-reduced-motion: reduce and sets the animation playback rate to 50x before the load.
  2. Waits for network idle, then up to 5 s for the fonts.
  3. Walks the page one viewport at a time with instant scrolls, at most 60 steps, and returns to the top. Stops with a log line when the window does not scroll (an inner element does).
  4. Waits for idle again, settles one second.
  5. Freezes the page: pauses media, takes away requestAnimationFrame in every frame, sets the playback rate to 0.

Then the MHTML, the PNG and the PDF. The PNG goes through Page.captureScreenshot with a clip capped at 16384px and at the walked height, so a feed that grows on every scroll cannot ask for a 60,000px capture.

Also:

  • Chromium runs with SwiftShader (--use-angle=swiftshader --enable-unsafe-swiftshader) instead of --disable-gpu. WebGL pages were a blank gradient before. The freeze is what keeps a software WebGL render loop from making one screenshot take 16 minutes (1390 s to 19 s on bruno-simon.com), and pausing media is what stopped browser.quit from hanging four minutes on a YouTube page (291 s to 29 s).
  • One retry in a new browser when the browser or its renderer dies, while less than half of CAPTURE_TIMEOUT is spent.
  • Elapsed seconds on every log line.
  • bin/capture-sample <urls or file>: runs the capturers on real URLs with no database rows and writes an index.html with every screenshot and log. Run it before changing a capturer.
  • docs/design.md, "Dynamic pages", and a note on the SwiftShader tradeoff in docs/deploy.md.

Results

A 15-URL matrix (scroll-animated site, Wikipedia, React docs, Apple, Framer, Webflow, Notion, The Verge, GitHub repo and issue, a PDF, a YouTube page, a Google Slides URL, a WebGL portfolio, a Substack) captures in 3 to 60 seconds each, with the content present down the whole page. interceptingoutliers.com is 7,181px with every chart and section.

Checks

  • bin/rails test: 71 runs, 0 failures. The page capturer has 10 unit tests against a fake browser; no test starts Chromium. bin/rubocop clean.
  • Adversarial review (Claude, with the Ferrum 0.20.1 source): twelve findings. Fixed in the last commit: Ferrum's idle wait returns false and never raised, so the "kept loading" log was dead; the retry only covered a dead browser process, not a renderer crash, and the helpers swallowed those; no height cap on the full-page screenshot; smooth-scroll pages lagged the walk; the freeze reached the top frame only; bin/capture-sample directory collisions and unescaped report fields; doc drift. Accepted and documented: the --enable-unsafe-swiftshader attack surface with the container as the boundary; pages that un-reveal on scroll up or pin sections to the scroll position still capture as they are.
  • Not run: docker build. Check in the built image that WebGL is on: chromium --headless --no-sandbox --use-angle=swiftshader --enable-unsafe-swiftshader --dump-dom 'data:text/html,<script>document.write(!!document.createElement("canvas").getContext("webgl"))</script>' prints true.

@jaspermayone
jaspermayone merged commit 156cefb into main Nov 9, 2026
7 of 9 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