-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Error: Cannot read property 'implementation' of null #548
Comments
Yes. I have a discussion with Mark today and we will update our solution ASAP. |
Thanks @Yuyz0112 I tried to make it as easy as possible for someone to work on. Let me know if there is anything else I can do to help. |
@Juice10 Sure, let me explain the issue more. In our current replay implementation, we use the "virtual parent", which is a fragment element to batch the DOM operations during apply mutations. This is a performance improvement because it reduces the amount of reflow. The implementation is currently not quite perfect because we are moving some existing DOM nodes into the virtual parent, which causes them to drop from the document. So @Mark-Fenng and I had an on-site discussion about the solution:
|
1. Do not use virtual parent optimization if the mutation targets have iframe elements as children. This will cause some performance regression but will be easy to add and ship. 2. If an iframe element has already been a child of a virtual parent, add the virtual parent back to the dom.
The Error
The current master version of rrweb triggers a "Cannot read property 'implementation' of null" error in some situations.
The Bug
I did some digging and it turns out iframes inside of a DocumentFragment don't have a
iframe.contentDocument
.rrweb/src/replay/index.ts
Lines 625 to 631 in 2b96a68
Whenever
applyMutation
gets called withuseVirtualParent: true
and a mutation containing an iframe, rrweb ends up callingbuildNodeWithSN
with an emptydoc
property which ends up triggering the error inbuildNode
on: SourceFixing this line and most other lines in
buildNode
should be quite easy, just replacingdoc
withdocument
should do the trick.For
buildNodeWithSN
however we need a different approach: SourceI wasn't really able to go beyond this unfortunately.
The Test (to reproduce the bug)
Add to
test/replayer.test.ts
:Contents of
test/events/iframe-events.ts
: iframe-events.ts.zipThe Version
I'm using rrweb's master branch
The text was updated successfully, but these errors were encountered: