Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat(replay): Add experimental dropRepetitiveMutations #15438

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

chargome
Copy link
Member

Adds a new experimental flag dropRepetitiveMutations to the replay integration options.

When enabled:

  • Adds a WeakMap to track recent mutations per DOM node
  • Adds mutation fingerprinting to detect identical mutations
  • Filters out duplicate mutations within configurable time window

ref #11517

@chargome chargome self-assigned this Feb 18, 2025
@billyvg
Copy link
Member

billyvg commented Feb 18, 2025

I'm wondering if we move this logic to be after rrweb processing (e.g. when we add to our event buffer). A [potentially big] downside is that we will always process the mutation w/ rrweb. I don't remember what the mutation records that the onMutation handler looks like (iirc they are just entries from MutationObserver), but will it be able to handle the case where we have the same set of dom elements that get removed and then readded?

A benefit of moving is that it'd be easier to test and verify changes -- we have example replays of different causes of infinite mutations to build against and we can use existing "normal" replays as inputs to our function to check correctness.

Maybe it's even possible to translate between the two (pre and post). WDYT?

@chargome
Copy link
Member Author

will it be able to handle the case where we have the same set of dom elements that get removed and then readded?

I think for this we would need to update the fingerprint logic in the pr to check on the removed and added nodes.

I'm wondering if we move this logic to be after rrweb processing

The testing aspect is def a big upside I would say. But yeah we would still run every mutation through the processing pipeline. Can you point me to some of the example replays, I would need to check how to convert them into tests

@billyvg
Copy link
Member

billyvg commented Feb 19, 2025

The testing aspect is def a big upside I would say. But yeah we would still run every mutation through the processing pipeline. Can you point me to some of the example replays, I would need to check how to convert them into tests

Yeah i'll work on finding new examples as the ones I had are out of retention now.

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.

2 participants