Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8069055
Remove INode (`node.__sn`) and use Mirror as source of truth (#868)
Juice10 Apr 6, 2022
627d54f
Fix mutation edge case when blocked class gets unblocked (#867)
rahulrelicx Apr 15, 2022
1c851c9
Record canvas snapshots N times per second (#859)
Juice10 Apr 18, 2022
94e0007
Test: Stylesheet append text node (#886)
Juice10 May 5, 2022
b49f505
Fix for issue #890 (#891)
dkozlovskyi May 9, 2022
c3de806
Perf: Apply the latest text mutation only (#885)
Juice10 May 9, 2022
0e91e84
* rrdom: add a diff function for properties
Juice10 May 12, 2022
4711692
Introduce benchmark tests and improve snapshot attributes traversing …
Yuyz0112 May 14, 2022
dc64d49
Chore: Add issue/pr template and general housekeeping tools and docs …
Juice10 May 22, 2022
1d7fcbd
Fix #904 (#906)
Juice10 May 31, 2022
11cd5ca
inline stylesheets when loaded
Juice10 May 31, 2022
3514b4f
set empty link elements to loaded by default
Juice10 Jun 1, 2022
1dcd7ea
Clean up stylesheet manager
Juice10 Jun 1, 2022
a345326
Remove attribute mutation code
Juice10 Jun 2, 2022
e7e78fb
Bump minimist from 1.2.5 to 1.2.6 (#902)
dependabot[bot] Jun 5, 2022
e0215fe
Speed up snapshotting of many new dom nodes (#903)
Juice10 Jun 6, 2022
1e784f6
highlight fixes after merge
Vadman97 Jun 2, 2022
2637be9
cleanup script
Vadman97 Jun 9, 2022
2cc2b5f
bump versions
Vadman97 Jun 9, 2022
3df6929
update version dependencies
Vadman97 Jun 10, 2022
789073d
fix rebuild not restoring inlined images
Vadman97 Jun 10, 2022
5d0842f
inline stylesheets when loaded
Juice10 May 31, 2022
8d38f64
fixup! inline stylesheets when loaded
Vadman97 Jun 10, 2022
9c64602
avoid crash on rrdom diff issues
Vadman97 Jun 13, 2022
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
Prev Previous commit
Next Next commit
Perf: Apply the latest text mutation only (#885)
* Perf: apply the latest text mutation only

* Find unique text mutations in one iteration
  • Loading branch information
Juice10 authored and Vadman97 committed Jun 2, 2022
commit c3de806b25702d1e2d2bcbcbeaf5525421407cd4
6 changes: 4 additions & 2 deletions packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
getBaseDimension,
hasShadowRoot,
isSerializedIframe,
uniqueTextMutations,
} from '../utils';
import getInjectStyleRules from './styles/inject-style';
import './styles/style.css';
Expand Down Expand Up @@ -185,9 +186,10 @@ export class Replayer {
this.fragmentParentMap.forEach((parent, frag) =>
this.restoreRealParent(frag, parent),
);

// apply text needs to happen before virtual style rules gets applied
// as it can overwrite the contents of a stylesheet
for (const d of mutationData.texts) {
for (const d of uniqueTextMutations(mutationData.texts)) {
this.applyText(d, mutationData);
}

Expand Down Expand Up @@ -1763,7 +1765,7 @@ export class Replayer {
Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);
}

d.texts.forEach((mutation) => {
uniqueTextMutations(d.texts).forEach((mutation) => {
let target = this.mirror.getNode(mutation.id);
if (!target) {
if (d.removes.find((r) => r.id === mutation.id)) {
Expand Down
20 changes: 20 additions & 0 deletions packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,3 +604,23 @@ export function hasShadowRoot<T extends Node>(
): n is T & { shadowRoot: ShadowRoot } {
return Boolean(((n as unknown) as Element)?.shadowRoot);
}

/**
* Returns the latest mutation in the queue for each node.
* @param {textMutation[]} mutations The text mutations to filter.
* @returns {textMutation[]} The filtered text mutations.
*/
export function uniqueTextMutations(mutations: textMutation[]): textMutation[] {
const idSet = new Set<number>();
const uniqueMutations: textMutation[] = [];

for (let i = mutations.length; i--; ) {
const mutation = mutations[i];
if (!idSet.has(mutation.id)) {
uniqueMutations.push(mutation);
idSet.add(mutation.id);
}
}

return uniqueMutations;
}
2 changes: 2 additions & 0 deletions packages/rrweb/typings/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export declare function getWindowHeight(): number;
export declare function getWindowWidth(): number;
export declare const isCanvasNode: (node: Node | null) => boolean;
export declare function isBlocked(node: Node | null, blockClass: blockClass): boolean;
export declare function isSerialized(n: Node, mirror: Mirror): boolean;
export declare function isIgnored(n: Node, mirror: Mirror): boolean;
export declare function isAncestorRemoved(target: Node, mirror: Mirror): boolean;
export declare function isTouchEvent(event: MouseEvent | TouchEvent): event is TouchEvent;
Expand Down Expand Up @@ -63,4 +64,5 @@ export declare function getBaseDimension(node: Node, rootIframe: Node): Document
export declare function hasShadowRoot<T extends Node>(n: T): n is T & {
shadowRoot: ShadowRoot;
};
export declare function getUniqueTextMutations(mutations: textMutation[]): textMutation[];
export {};