Skip to content

A long capture succeeded, then the popup reported it failed - #67

Open
vhladiienko wants to merge 1 commit into
Open-Capture:mainfrom
vhladiienko:fix/popup-preview-message-cap
Open

vhladiienko wants to merge 1 commit into
Open-Capture:mainfrom
vhladiienko:fix/popup-preview-message-cap

Conversation

@vhladiienko

Copy link
Copy Markdown

Summary

The capture response to the popup carried every output PNG as full-size base64 data URLs. Chromium caps extension messages at ~64MiB (serialized length, so base64 costs 4 bytes per 3 raw bytes), and a long page's capture crossed it — so the response died after the capture had already succeeded. The popup showed Error: Message exceeded maximum allowed size of 64MiB. and a blank preview over a healthy capture: the bytes were already in blob-store, which is why Save PNG, PDF export, history and the editor (all blob-store readers) kept working.

The response now carries a small thumbnail instead — the first output image re-encoded at 320px wide through shot-core's existing cropAndEncode, a few KB that cannot reach the cap. Full-size bytes stay in blob-store, exactly where everything that needs them already reads them.

 background handleRequest (captureFullPage / captureVisible / captureSelectedArea)
   response to the popup over chrome.runtime.sendMessage
-    pngDataUrls: every output PNG, base64        ← ~64MiB+ on a long page
+    previewDataUrl: first image at 320px wide    ← a few KB

The popup uses the response image in exactly one place — the preview <img> — so the thumbnail covers all of its consumption. Split captures change nothing semantically: the preview always showed the first image only; before, it also shipped every part's bytes, which is precisely what overflowed.

Evidence

  • Before: full-page capture of a page whose output PNG encoded ≥ ~48MiB raw (a detailed 30,000px segment does) → popup showed the browser's error text and an empty #preview, while savePngs from the same state saved every file fine.
  • After: the response is a few KB, immune to the cap; the popup reports the capture normally with a preview thumbnail.

Full runs on this branch: npm run typecheck ✓, npm test ✓ (13 files, 110 tests). The e2e suite was not run for this change; no spec asserts on the popup response shape (pngDataUrls appeared only in the three response sites, types.ts, and the popup preview).

Merge Danger

Door: two-way — reverting the single commit restores the old response shape exactly.

Blast Radius: small — the popup response and the popup's preview read; blob-store, history, editor handoff and PDF paths untouched. Merges cleanly with #66 (both touch popup.ts; verified with merge-tree, regions are disjoint).

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