GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — perf(record): reuse stylesheets when parsing style declarations by gunil0610 · Pull Request #339 · getsentry/rrweb

Conversation

@gunil0610

@gunil0610 gunil0610 commented Oct 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Why

Inline style parsing creates a new CSSStyleSheet on every call. Reuse one sheet per parser to avoid repeated allocations.

This change also addresses stylesheet accumulation observed on an animated development page with Chrome's CSS Inspector enabled. Heap analysis found strong paths through InspectorCSSAgent to the allocated stylesheets.

After applying the same reuse change to the SDK bundle, a follow-up observation recorded no further CSS.styleSheetAdded events after startup while animation and Replay remained active. This was a single instrumented application run, not an isolated memory benchmark.

The allocation concern noted in #286 deserves explicit coverage. This change calls replaceSync() to replace the rules rather than changing a cached rule's declarations. The native browser test retains earlier declarations and verifies that later parses do not change their values.

What changed

  • Lazily create one stylesheet per StyleDeclarationParser.
  • Cover repeated parsing, parser isolation, and fallback after construction or replacement fails.
  • Add a native browser recorder test for retained declarations, emitted diffs, !important, and property removal.

Scope

Inline style parsing during recording. No public API or event format changes. This PR establishes allocation reduction, without a runtime speed or memory benchmark claim.

Blast Radius

Repeated style mutations reuse parser state. Native browser coverage checks that earlier parse results remain stable, and unit tests cover the existing detached-element fallback.

Verification

  • yarn build:all and yarn check-types passed across the workspace.
  • In packages/rrweb, PUPPETEER_HEADLESS=true yarn vitest run test/record.test.ts test/style-declaration-parser.test.ts passed all 36 tests with Chrome Headless Shell 146.0.7680.153 selected via PUPPETEER_EXECUTABLE_PATH.
  • The native recorder regression fails without reuse (expected 2 to be 1). Changed production code passes ESLint, and all changed files pass Prettier. A separate native check with style-src 'none' produced no CSP violations before or after the change.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
gunil0610 and others added 3 commits October 21, 2026 01:32
@gunil0610 @codex
test(record): cover stylesheet reuse in style parsing
5dd0490
Co-Authored-By: OpenAI Codex <[email protected]>
@gunil0610 @codex
fix(record): reuse stylesheets when parsing style declarations
d30fd40
Co-Authored-By: OpenAI Codex <[email protected]>
@gunil0610 @claude
test(record): verify native stylesheet reuse preserves declarations
0c110c0
Co-Authored-By: OpenAI Codex gpt-6-astra <[email protected]>
@Lms24

Lms24 commented Oct 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I'm going to close this issue for multiple reasons:

  1. The retention you observed comes from Chrome DevTools' InspectorCSSAgent keeping constructed stylesheets alive while the CSS inspector is attached. Without DevTools, these sheets are short-lived and get collected normally, so we don't see a production issue to fix here.
  2. We also previously chose not to cache the sheet (see fix: use CSS Declaration replaceSync to parse styles to avoid CSP violations #286) to avoid returned declarations sharing mutable state.
  3. There is no issue about this problem. It would have been much easier to discuss this in an issue prior to submitting a vibe-coded PR.
  4. The PR description is 100% AI generated and low effort. Please do OSS maintainers a favour and either think about the PR and how to describe it or don't open a PR at all.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Lms24 Lms24 closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@gunil0610 @Lms24
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.