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

Fix performance of splitCssText #1615

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

eoghanmurray
Copy link
Contributor

@eoghanmurray eoghanmurray commented Dec 18, 2024

See #1603 for an excellent bug report.

I didn't include the benchmark from that report as it didn't demonstrate the pathological cases that were being experienced in the wild, but rather just the degree of slowdown of the 'split' vs. 'no split' code paths.


See #1437 for the context as to why splitCssText exists;
To recap, a <style> element can have multiple text nodes. We currently serialize by processing styleEl.sheet.cssRules into a single string, but if one of the text nodes is programmatically modified (via a text mutation), then we want to be able to map the mutation back to only modify the relevant part, and not blow away the entire css text if we were not to do the split in the first place.

This PR massively improves the performance of the splitting in the case where we need to search through large strings to find similar parts, we need to compare after normalization so there's a lot of back and forth. This PR changes that process to more like a binary search rather than a crawling search which was producing the pathological performance.

Copy link

changeset-bot bot commented Dec 18, 2024

🦋 Changeset detected

Latest commit: e5f22e3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
rrweb-snapshot Patch
rrweb Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/replay Patch
@rrweb/record Patch
@rrweb/types Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/web-extension Patch
rrvideo Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eoghanmurray eoghanmurray changed the title Fix performance of aplitCssText Fix performance of splitCssText Dec 18, 2024
Failed to launch the browser process! [...FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel ...
Failed to launch the browser process! [...FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel ...
…fault css values from shorthand properties when retrieved via `sheet.rules[0].cssText`
… if this LTS version also solves:

Failed to launch the browser process! [...FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel ...
@eoghanmurray
Copy link
Contributor Author

There's a lot of commits in here that can be ignored as I was iterating trying to fix an issue in Github Actions

@eoghanmurray
Copy link
Contributor Author

eoghanmurray commented Jan 3, 2025

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant