Skip to content

Conversation

@Juice10
Copy link
Member

@Juice10 Juice10 commented Apr 4, 2022

Currently we can't record rrweb with rrweb because both the replay and recording use the node.__sn attribute which causes id collisions.

To move away from INode's (nodes with __sn attribute) this PR uses the Mirror to save all serialized data, and id numbers.

This PR could potentially make it easier for multiple rrweb recordings to happen at the same time without the recording sessions needing to use the exact same ids for the same nodes.

Breaking change

The mirror was moved to rrweb-snapshot, has its own class, and the map attribute isn't supported anymore. We could create a .map fallback to help with backward compatibility.

Copy link
Member

@YunFeng0817 YunFeng0817 left a comment

Choose a reason for hiding this comment

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

👍A great patch that will solve many issues and inconveniences in the current branch.
There are only several typecast that have space to improve.

@Yuyz0112
Copy link
Member

Yuyz0112 commented Apr 5, 2022

This PR is a lifesaver, INode may be one of the worst types I've designed:)

@Juice10 Juice10 requested a review from Yuyz0112 April 6, 2022 11:35
@Yuyz0112 Yuyz0112 merged commit e4f680e into master Apr 6, 2022
@YunFeng0817 YunFeng0817 deleted the node-id-map branch April 7, 2022 01:49
Vadman97 pushed a commit to highlight/rrweb that referenced this pull request Jun 2, 2022
* Move ids to weakmap

* Fix typo

* Move from INode to storing serialized data in mirror

* Update packages/rrweb-snapshot/src/rebuild.ts

Co-authored-by: Yun Feng <[email protected]>

* Remove unnessisary `as Node` typecastings

Fixes: rrweb-io/rrweb#868 (comment)

* Remove unnessisary `as unknown as ...`

* Remove unnessisary `as unknown as ...`

* Reset mirror when recording starts

Solves: rrweb-io/rrweb#868 (comment)

* API has changed for snapshot, change test to reflect that

* Allow for es5 compatibility

* Remove unnessisary as unknown as ... and change test to reflect the API change

* Refactor mirror to remove `nodeIdMap`

Fixes: rrweb-io/rrweb#868 (comment)

Co-authored-by: Yun Feng <[email protected]>
@Juice10 Juice10 added the 2.0 label Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants