Skip to content
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

perf(replayer): Prevent infinte loops with resolve trees #235

Draft
wants to merge 1 commit into
base: sentry-v2
Choose a base branch
from
Draft
Changes from all commits
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
6 changes: 5 additions & 1 deletion packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@
* pause when there are some canvas drawImage args need to be loaded
*/
private async preloadAllImages(): Promise<void[]> {
let beforeLoadState = this.service.state;

Check warning on line 1058 in packages/rrweb/src/replay/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/replay/index.ts#L1058

[@typescript-eslint/no-unused-vars] 'beforeLoadState' is assigned a value but never used.
const stateHandler = () => {
beforeLoadState = this.service.state;
};
Expand Down Expand Up @@ -1090,8 +1090,8 @@
const ctx = canvas.getContext('2d');
const imgd = ctx?.createImageData(canvas.width, canvas.height);
let d = imgd?.data;
d = JSON.parse(data.args[0]) as Uint8ClampedArray;

Check warning on line 1093 in packages/rrweb/src/replay/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/replay/index.ts#L1093

[@typescript-eslint/no-unused-vars] 'd' is assigned a value but never used.
ctx?.putImageData(imgd!, 0, 0);

Check warning on line 1094 in packages/rrweb/src/replay/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/replay/index.ts#L1094

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
}
}
private async deserializeAndPreloadCanvasEvents(
Expand Down Expand Up @@ -1587,7 +1587,7 @@
// If the parent is attached a shadow dom after it's created, it won't have a shadow root.
if (!hasShadowRoot(parent)) {
(parent as Element | RRElement).attachShadow({ mode: 'open' });
parent = (parent as Element | RRElement).shadowRoot! as Node | RRNode;

Check warning on line 1590 in packages/rrweb/src/replay/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/replay/index.ts#L1590

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
} else parent = parent.shadowRoot as Node | RRNode;
}

Expand Down Expand Up @@ -1760,6 +1760,7 @@
});

const startTime = Date.now();
const resolvedTreeNodes = new WeakSet();
while (queue.length) {
// transform queue to resolve tree
const resolveTrees = queueToResolveTrees(queue);
Expand All @@ -1780,7 +1781,10 @@
);
} else {
iterateResolveTree(tree, (mutation) => {
appendNode(mutation);
if (!resolvedTreeNodes.has(mutation)) {
resolvedTreeNodes.add(mutation);
appendNode(mutation);
}
});
}
}
Expand Down
Loading