Repository navigation
fix(replay): Keep the full snapshot when a canvas is tainted - #365
Conversation
A canvas tainted by cross-origin data throws a SecurityError from getImageData and toDataURL. With recordCanvas on, that error escaped serializeElementNode and aborted the whole document snapshot. In record(), the Meta event was already emitted, so the recording got a Meta event with no FullSnapshot, observe(document) never ran, and players could not render the replay. Catch the error for that canvas and skip its pixel data instead. Co-Authored-By: George Gritsouk <[email protected]>
gggritso
left a comment
There was a problem hiding this comment.
Looks quite decent, just a few questions
|
@cursor review |
|
Is it possible to add some kind of custom attribute to the "tainted" |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit db4438b. Configure here.
|
Yes, it's possible, and rrweb already has the pattern for it: internal Precedent
What it would take
I'd keep that out of this PR. This PR only restores the snapshot. The marker changes the recorder/player contract and touches rebuild, rrdom, and the Sentry player, so it deserves its own review. I can open it as a stacked follow-up if you want it. |
|
Oh, so there's already mechanisms present for blocked elements! Can we treat a "tainted" canvas as blocked and get this for free? |
|
Re: treating a tainted canvas as blocked. Mostly no. The blocked path wouldn't change what a tainted canvas looks like in Sentry today. For a blocked element,
So if we want a tainted canvas to look different on replay, the dedicated |
logaretm
left a comment
There was a problem hiding this comment.
A couple of comments, other than that looks good.
|
@logaretm thanks for taking a look! The |
logaretm
left a comment
There was a problem hiding this comment.
LGTM, the WeakSet works here ✅
When
recordCanvasis on,serializeElementNodereads pixel data from each canvas. On a canvas that has cross-origin data (i.e., images), this throws aSecurityError. Nothing catches that error, so it aborts the whole snapshot. The resulting replay is not playable since there's no snapshot to render from.The upstream rrweb repo has a few reports of this, and some agreement that just
trycatching the error is probably fine, so that's what we're doing here. The canvas ends up blank, but the rest of the snapshot is kept.I expect that as a follow-up we'll somehow "decorate" these blocked canvases so users can see them in the UI. We also might add a bit of error handling to the product so if someone has one of these busted replays they get a notice.
Refs REPLAY-1049
via George Gritsouk.
--
View Session [Sentry]