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

fix duplicated shadow dom #1095

Merged
merged 7 commits into from
Feb 12, 2023
Merged

fix duplicated shadow dom #1095

merged 7 commits into from
Feb 12, 2023

Conversation

YunFeng0817
Copy link
Member

Bug

There are piles of duplicated nodes after a recorder takes a new full snapshot manually.
Duplicated node creation may cause unexpected errors in the replayer.

Fix

  1. Clean observers of shadow dom manager before taking new full snapshots.
  2. Add a fallback on the replayer side to make it stable when data has duplicated nodes for other kinds of reasons.

@YunFeng0817 YunFeng0817 requested a review from Juice10 January 17, 2023 10:18
@bhavitsharma
Copy link

Hey @Mark-Fenng, why do you mean by taking fullsnapshot manually? and why are there duplicated nodes? Do you mean taking fullsnapshot by manually starting the recording again (i.e. after rrweb has already taken a full-snapshot)? Why do we need this workaround then? Shouldn't be we cleaning up all the observers in that case?

@YunFeng0817
Copy link
Member Author

Hey @Mark-Fenng, why do you mean by taking fullsnapshot manually? and why are there duplicated nodes? Do you mean taking fullsnapshot by manually starting the recording again (i.e. after rrweb has already taken a full-snapshot)? Why do we need this workaround then? Shouldn't be we cleaning up all the observers in that case?

Taking fullsnapshot manually means call rrweb.takeFullSnapshot(true) after the recorder started.

@YunFeng0817 YunFeng0817 added bug Something isn't working 2.0 labels Jan 21, 2023
Copy link

@bhavitsharma bhavitsharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for applying suggestions. The PR looks great to me!

Comment on lines +242 to +243
JSON.stringify(a.attributes) ===
JSON.stringify((b as elementNode).attributes) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a slow call to do, aren't you afraid this will slow down repeated rrweb.takeFullSnapshot(true)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also what happens if a node gets a new attribute since the last time it was snapshotted? Will this node get added twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a slow call to do, aren't you afraid this will slow down repeated rrweb.takeFullSnapshot(true)?

Yes you are right, this function is slow. It's in the rebuilt.ts so I don't think this can slow down the takeFullSnapshot function. If the data events are correct, the program won't go to this path. This comparison will only be used when rrweb ingests any problematic data.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also what happens if a node gets a new attribute since the last time it was snapshotted? Will this node get added twice?

If the recorder works well, the incremental data will only change the node's attribute rather than totally recreate the node through this path.
In case the program goes here, the node will get added twice as you said. But honestly, I don't know what kind of error event data can lead to this. I wrote this function as a fallback.
Do you have any suggestions for improving the code here?

@changeset-bot
Copy link

changeset-bot bot commented Feb 11, 2023

🦋 Changeset detected

Latest commit: 08e4b1c

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

This PR includes changesets to release 2 packages
Name Type
rrweb-snapshot Patch
rrweb 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

@YunFeng0817 YunFeng0817 requested a review from Juice10 February 11, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants