Skip to content

Collapse multiple text mutations when frozen / throttled - #1933

Open
eoghanmurray wants to merge 13 commits into
mainfrom
collapse-frozen-mutations
Open

eoghanmurray wants to merge 13 commits into
mainfrom
collapse-frozen-mutations

Conversation

@eoghanmurray

@eoghanmurray eoghanmurray commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

This PR does two things:

  • Ensure we don't emit multiple text or attribute mutations against the same node while throttled or when mutations are frozen
  • Pull in the 'configurable throttling on mutation emission' from Implement configurable throttling on mutation emission #1694 but re-implement on a per-element basis, so a change to a well behaved element isn't delayed by another noisier one

Replay should be unaffected, as the replayer would have applied the last mutation in the series, which should end up in the same state at that timestamp. The test data shows some de-duplication of text/attributes after this change, which is proof positive.

Tech note:

  • Also recognize that the additional WeakMap added in perf(rrweb): attribute mutation optimization #1343 in relation to attributes/attributeMap can be improved by replacing both variables with a single Map. The array was holding strong references to the Node anyway in the attributeCursor; these were freed at the end after // reset and this is still the case after this change

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c7d2802

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
rrweb Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/all Patch
@rrweb/browser-client Patch
@rrweb/packer Patch
@rrweb/replay Patch
rrdom-nodejs Patch
rrdom Patch
rrvideo Patch
rrweb-player Patch
rrweb-snapshot Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-network-record Patch
@rrweb/rrweb-plugin-network-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eoghanmurray
eoghanmurray force-pushed the collapse-frozen-mutations branch from ce9ff62 to 179b3f9 Compare September 8, 2026 12:04
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Changes

Size change: +1.42 kB (+0.01%) | Total size: 10430.46 kB

all - 1975.72 kB -> 1976.08 kB (+364 B (+0.02%))
File Base PR Diff
all.cjs 567.91 kB 568.03 kB +121 B (+0.02%)
all.js 567.58 kB 567.70 kB +121 B (+0.02%)
all.umd.cjs 571.12 kB 571.24 kB +121 B (+0.02%)
all.umd.min.cjs 269.12 kB 269.12 kB +1 B (+0.00%)
browser-client - 670.07 kB -> 670.42 kB (+364 B (+0.05%))
File Base PR Diff
browser-client.cjs 192.15 kB 192.26 kB +121 B (+0.06%)
browser-client.js 191.92 kB 192.04 kB +121 B (+0.06%)
browser-client.umd.cjs 194.97 kB 195.09 kB +121 B (+0.06%)
browser-client.umd.min.cjs 91.03 kB 91.03 kB +1 B (+0.00%)
record - 552.68 kB -> 553.04 kB (+364 B (+0.06%))
File Base PR Diff
record.cjs 158.46 kB 158.58 kB +121 B (+0.07%)
record.js 158.38 kB 158.49 kB +121 B (+0.07%)
record.umd.cjs 159.79 kB 159.91 kB +121 B (+0.07%)
record.umd.min.cjs 76.05 kB 76.06 kB +1 B (+0.00%)
rrweb - 1913.90 kB -> 1914.26 kB (+364 B (+0.02%))
File Base PR Diff
rrweb.cjs 551.07 kB 551.19 kB +121 B (+0.02%)
rrweb.js 550.77 kB 550.89 kB +121 B (+0.02%)
rrweb.umd.cjs 552.29 kB 552.41 kB +121 B (+0.02%)
rrweb.umd.min.cjs 259.77 kB 259.78 kB +1 B (+0.00%)

@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown
@rrweb/all

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/all@c7d2802

@rrweb/browser-client

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/browser-client@c7d2802

@rrweb/packer

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/packer@c7d2802

@rrweb/record

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/record@c7d2802

@rrweb/replay

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/replay@c7d2802

rrdom

npm i https://pkg.pr.new/rrweb-io/rrweb/rrdom@c7d2802

rrdom-nodejs

npm i https://pkg.pr.new/rrweb-io/rrweb/rrdom-nodejs@c7d2802

rrvideo

npm i https://pkg.pr.new/rrweb-io/rrweb/rrvideo@c7d2802

rrweb

npm i https://pkg.pr.new/rrweb-io/rrweb@c7d2802

rrweb-player

npm i https://pkg.pr.new/rrweb-io/rrweb/rrweb-player@c7d2802

rrweb-snapshot

npm i https://pkg.pr.new/rrweb-io/rrweb/rrweb-snapshot@c7d2802

@rrweb/types

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/types@c7d2802

@rrweb/utils

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/utils@c7d2802

@rrweb/rrweb-plugin-canvas-webrtc-record

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-canvas-webrtc-record@c7d2802

@rrweb/rrweb-plugin-canvas-webrtc-replay

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-canvas-webrtc-replay@c7d2802

@rrweb/rrweb-plugin-console-record

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-console-record@c7d2802

@rrweb/rrweb-plugin-console-replay

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-console-replay@c7d2802

@rrweb/rrweb-plugin-network-record

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-network-record@c7d2802

@rrweb/rrweb-plugin-network-replay

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-network-replay@c7d2802

@rrweb/rrweb-plugin-sequential-id-record

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-sequential-id-record@c7d2802

@rrweb/rrweb-plugin-sequential-id-replay

npm i https://pkg.pr.new/rrweb-io/rrweb/@rrweb/rrweb-plugin-sequential-id-replay@c7d2802

commit: c7d2802

…e e.g. style attribute diffs over and over while frozen or during throttling

 - this mirrors the other pattern from this PR for text mutations
 - more importantly, the serialization of new 'add' nodes has always happened upon emission, so the deferred computation is by design (no point in serializing something that may have been added then quickly removed)
…`sampling.mutation` ms setting

 - can prevent overly frequent (javascript based) animation per second on the same attribute; the mutation buffer will emit a single change at the end if throttled changes are against the same element
…default in rrweb package; useful for experimenting with live-stream in worktrees where there's been no previous build
… attributes/textContent on a per-element basis rather than globally (so a noisy element can't delay a well behaved one)
@eoghanmurray
eoghanmurray force-pushed the collapse-frozen-mutations branch from 365f778 to 49c6e6c Compare September 21, 2026 22:00
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