Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/app/utils/replays/hooks/useExtractDomNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useExtractDomNodes({
}): UseQueryResult<Map<ReplayFrame, Extraction>> {
return useQuery({
queryKey: ['getDomNodes', replay],
queryFn: () => replay?.getExtractDomNodes(),
queryFn: () => replay?.getExtractDomNodes({withoutStyles: true}),
enabled: Boolean(replay),
gcTime: Infinity,
});
Expand Down
63 changes: 48 additions & 15 deletions static/app/utils/replays/replayReader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,26 @@ export default class ReplayReader {
return this.processingErrors().length;
};

getExtractDomNodes = memoize(async () => {
if (this._fetching) {
return null;
}
const {onVisitFrame, shouldVisitFrame} = extractDomNodes;

const results = await replayerStepper({
frames: this.getDOMFrames(),
rrwebEvents: this.getRRWebFrames(),
startTimestampMs: this.getReplay().started_at.getTime() ?? 0,
onVisitFrame,
shouldVisitFrame,
});
getExtractDomNodes = memoize(
async ({withoutStyles}: {withoutStyles?: boolean} = {}) => {
if (this._fetching) {
return null;
}
const {onVisitFrame, shouldVisitFrame} = extractDomNodes;

const results = await replayerStepper({
frames: this.getDOMFrames(),
rrwebEvents: withoutStyles
? this.getRRWebFramesWithoutStyles()
: this.getRRWebFrames(),
startTimestampMs: this.getReplay().started_at.getTime() ?? 0,
onVisitFrame,
shouldVisitFrame,
});

return results;
});
return results;
}
);

getClipWindow = () => this._clipWindow;

Expand Down Expand Up @@ -534,6 +538,35 @@ export default class ReplayReader {
return eventsWithSnapshots;
});

/**
* Filter out style mutations as they can cause perf problems especially when
* used in replayStepper
*/
getRRWebFramesWithoutStyles = memoize(() => {
return this.getRRWebFrames().map(e => {
if (
e.type === EventType.IncrementalSnapshot &&
'source' in e.data &&
e.data.source === IncrementalSource.Mutation
Comment on lines +548 to +550
Copy link
Member

Choose a reason for hiding this comment

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

i had this same bug! forgetting about FullSnapshot.

there's a new util to help:

import {isRRWebChangeFrame} from 'sentry/utils/replays/types';

in the other places where I've called the util i did not memoize it... because i was lazy and didn't add to ReplayReader; just chained some calls. That could probably be unified.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, we don't care about full snapshots, only incremental

Copy link
Member Author

Choose a reason for hiding this comment

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

(I did copy&paste this from elsewhere though, so would be good to refactor into a helper)

) {
return {
...e,
data: {
...e.data,
adds: e.data.adds.filter(
add =>
!(
(add.node.type === 3 && add.node.isStyle) ||
(add.node.type === 2 && add.node.tagName === 'style')
)
),
},
};
}
return e;
});
});

getRRwebTouchEvents = memoize(() =>
this.getRRWebFramesWithSnapshots().filter(
e => isTouchEndFrame(e) || isTouchStartFrame(e)
Expand Down
Loading