rrweb icon indicating copy to clipboard operation
rrweb copied to clipboard

rrweb sends message to cross-origin iframe to force snapshot

Open colingm opened this issue 9 months ago • 6 comments

We often manually take snapshots in cross origin frame situations and were running into problems with no longer having the content of cross origin frames. We noticed that if we sent along a message to tell the cross origin frame to take a new snapshot whenever the parent frame took one then it resolved this issue.

colingm avatar May 01 '24 18:05 colingm

🦋 Changeset detected

Latest commit: 01d107f17d8db603e23895a2e7dd2fbfeb4f6e15

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

This PR includes changesets to release 8 packages
Name Type
rrweb Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/types Patch
@rrweb/web-extension Patch
rrvideo 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

changeset-bot[bot] avatar May 01 '24 18:05 changeset-bot[bot]

Is there a possibility that this will duplicate the regular way to take an iframe snapshot (when the contentDocument is accessible)? I'm also curious as to if there is a problem with communicating the snapshot back up to the parent context when the contentDocument can't be accessed. Some tests to demonstrate the novel scenario and prevent future regression would be appreciated.

eoghanmurray avatar May 09 '24 09:05 eoghanmurray

@eoghanmurray I am not quite sure if this can be triggered before the inner frame ends up being ready, will need to test that specifically. In practice we don't run into that problem since we don't try to initialize rrweb until the document is ready ourselves so it is worth double checking.

In general the idea that the top frame taking a snapshot (either due to the checkoutN options or manually) means you lose the inner frame entirely was definitely the major concern but it is a good idea to make sure it doesn't mess with delayed initializations for the inner frames.

colingm avatar May 09 '24 12:05 colingm

Adding a note here as doing some testing with timing of things and have found some oddities where it might not be behaving as expected due to the ordering of definition for takeFullSnapshot and iframeManager. Working through some testing and other options with the team.

colingm avatar May 15 '24 14:05 colingm

fwiw we also have this use case!

dobrynin avatar Jun 19 '24 20:06 dobrynin

@Juice10 yeah sorry I have kind of let this languish unfortunately. So we actually found with the original version we had a weird race condition where it wasn't doing what we thought most of the time. We changed how we passed in the function (a setter now being called later) and that seemed to address the odd behavior we saw. Now just to write the tests 😅

colingm avatar Aug 01 '24 19:08 colingm