Encode inlineImages as webp instead of default lossless PNG (#44) - #45
Open
SaintPepsi wants to merge 1 commit into
Open
Encode inlineImages as webp instead of default lossless PNG (#44)#45SaintPepsi wants to merge 1 commit into
SaintPepsi wants to merge 1 commit into
Conversation
rrweb's inlineImages draws each <img> to canvas and re-encodes it; without dataURLOptions that defaults to lossless PNG, which on image-heavy pages is the dominant contributor to export size. The recording linked from #44 was 87.6 MB, almost entirely lossless PNGs of Village Cinemas' poster/banner images. REPLAY_DESIGN.md §4 specced webp@0.6 for exactly this reason but it never made it into the actual record() call. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 22, 2026
SaintPepsi
added a commit
that referenced
this pull request
Jul 22, 2026
…mment - docs/feature-set/bug-report.md claimed both the webp image fix (a separate, non-stacked PR — #45) and this PR's compression fix were shipped. Since these PRs merge independently, that overclaims when #46 lands without #45. Scope the wording to what this PR actually does. - encodeOjData(undefined) previously produced a corrupt blob (JSON.stringify returns the *value* undefined, not a string) that would only fail later, at decode time, far from the actual cause. Throw at the source instead. Not reachable from any current call site — report-builder.js and redact-report.mjs always pass real objects — but a latent footgun for future callers of what's designed as a reusable codec. - Corrected the corruption-canary comment in redact-report.mjs: it now bounds gzip+base64 output, not raw-JSON token substitution, so the old "output ≈ input" justification no longer described the actual mechanism. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
inlineImagesdraws each<img>to canvas and re-encodes it; withoutdataURLOptionsthat defaults to lossless PNG, which on image-heavy pages is the dominant contributor to export size.REPLAY_DESIGN.md§4 already specceddataURLOptions: { type: 'image/webp', quality: 0.6 }for exactly this reason; it never made it into the actualrecord()call insrc/rrweb-recorder.js. This PR wires it in.This is fix #1 of the 3 mitigations from my comment on #44 (compression of the event stream via
@rrweb/packer/fflate, and the originally-speccedsampling/slimDOMOptions, are separate, larger follow-ups — not attempted here).Test plan
npm run build— bundles clean,dist/rrweb-recorder.jsunaffected in size classbun test test/— 88/90 pass; the 2 failures (test/packaging.test.js) are pre-existing onmain, unrelated to this change: one is a Windows path-separator artifact in the packaged-file check, the other isdocs/STORE_LISTING.mdgenuinely missing CWS justification blocks for several permissions (a real doc gap, not a path issue) — confirmed by running the same test against unmodifiedmainbun test test/recorder.test.js— 9/9 pass, including a new causal-guard assertion (capturedOpts.dataURLOptions) mirroring the existinginlineImagesguarddataURLOptionsand rerantest/recorder.test.js— the new assertion goes red as expected, confirming it actually catches a regression🤖 Generated with Claude Code
Note: #47 (
fix/44-sampling-slim-dom) edits the samerecord({...})call block insrc/rrweb-recorder.js. Both are independent, non-stacked PRs — merging both will hit a textual (not semantic) conflict at that call site that needs manual reconciliation; the options compose fine (inlineImages,dataURLOptions,sampling,slimDOMOptionsare all independent keys).