Repository navigation
Collapse multiple text/attribute mutations when throttled (or frozen) & add per-element throttling config - #1933
Open
eoghanmurray wants to merge 16 commits into
Open
eoghanmurray wants to merge 16 commits into
eoghanmurray wants to merge 16 commits into
Conversation
🦋 Changeset detectedLatest commit: 29a4ec8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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
force-pushed
the
collapse-frozen-mutations
branch
from
September 8, 2026 12:04
ce9ff62 to
179b3f9
Compare
Contributor
Bundle Size ChangesSize change: +1.42 kB (+0.01%) | Total size: 10430.46 kB
|
| 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%) |
eoghanmurray
force-pushed
the
collapse-frozen-mutations
branch
from
September 9, 2026 11:50
a8e5ab7 to
365f778
Compare
@rrweb/all
@rrweb/browser-client
@rrweb/packer
@rrweb/record
@rrweb/replay
rrdom
rrdom-nodejs
rrvideo
rrweb
rrweb-player
rrweb-snapshot
@rrweb/types
@rrweb/utils
@rrweb/rrweb-plugin-canvas-webrtc-record
@rrweb/rrweb-plugin-canvas-webrtc-replay
@rrweb/rrweb-plugin-console-record
@rrweb/rrweb-plugin-console-replay
@rrweb/rrweb-plugin-network-record
@rrweb/rrweb-plugin-network-replay
@rrweb/rrweb-plugin-sequential-id-record
@rrweb/rrweb-plugin-sequential-id-replay
commit: |
…mutations are frozen
…on that this PR fixes; the text is only set to 'yellow' in the test once
…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
force-pushed
the
collapse-frozen-mutations
branch
from
September 21, 2026 22:00
365f778 to
49c6e6c
Compare
The 'error-handler' test ("triggers for errors from mutation observer")
hung. Since attributes are now resolved lazily at emit time
(resolveAttributes reads getAttribute), a throw there escaped emit before
the buffer was consumed, leaving the offending node in attributesMap. It
then re-threw on the next emit — and because the errorHandler writes to
the DOM, that triggered a fresh mutation → emit → re-throw → unbounded
loop. Even without a DOM-mutating handler, one bad node would poison
every subsequent emit and kill recording for the page.
Consume the texts/attributes maps (swap in the held maps) before building
the payload, so a throw during resolveAttributes can't leave the entry
behind: the error still reaches the errorHandler once, and recording
continues on the next mutation.
Update the test's expected message (m.target.getAttribute →
target.getAttribute) since the throwing call moved from processMutation
to resolveAttributes.
… a delayed mutation emission is short circuit triggered by another event (another type of forcing)
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.
This PR does two things:
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:
WeakMapadded in perf(rrweb): attribute mutation optimization #1343 in relation toattributes/attributeMapcan be improved by replacing both variables with a singleMap. The array was holding strong references to the Node anyway in the attributeCursor; these were freed at the end after// resetand this is still the case after this change