Skip to content

Batch mutable stylesheet publication - #315

Merged
wieslawsoltes merged 2 commits into
mainfrom
fix/batched-stylesheet-publication-297
Sep 17, 2026
Merged

wieslawsoltes merged 2 commits into
mainfrom
fix/batched-stylesheet-publication-297

Conversation

@wieslawsoltes

@wieslawsoltes wieslawsoltes commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Repeated CSSStyleSheet.insertRule/deleteRule calls rebuilt and published the owning <style> source after every mutation. In the unchanged Code OSS theme continuation, that repeated work held a required promise checkpoint for seconds and delayed the remote extension-host initialization send.

This change keeps the live CSSOM wrapper and synchronous observable behavior, stages one final serialized source per stylesheet owner, and materializes it before observable style/layout reads or the checkpoint boundary. A first source larger than the 32 MiB coalescing budget takes an immediate nonqueued path, so pending storage stays bounded. It also preserves staged state across disconnect/reconnect, clears it on direct text replacement/navigation/teardown, and accounts for retained wrappers/source text in runtime memory metrics.

Closes #297.

Validation

  • Native stylesheet CSSOM, Monaco topology, cascade-scaling, and 31-navigation lifecycle gates pass on exact base 486e7931; merged head was fe4bba7d. The exact-head Linux runner passed the runtime browser compatibility step, and Node 24.18.1 CSSOM compatibility passes 8/8.
  • Product-shaped 20-cycle exact-head gate: p95 3.985 ms, max 5.410 ms, layout +22, scene +1, flat heap/RSS, and sync → microtask → timer ordering. The oversized-source regression also passes low-memory cleanup.
  • Native WebScene and Chrome 153 contract: 5/5 subtests each.
  • Unchanged packaged Code OSS on b69f931d: exact remote root/provider, 5 resolved children, 5 Explorer model children, 5 rendered rows; resolve 97.582 ms, first child 1,487.051 ms, Ready→Initialized 759.817 ms, init send→native WebSocket entry 374.573 ms. The no-candidate control was 5,215.651 ms Ready→Initialized and 3,309.197 ms send→entry.
  • The branch was subsequently rebased over CSS metadata PR Generate shared CSS property identity metadata #313, parser/resource-interception PR Intercept connected resources through Service Workers #310, and native CSS property-identity PR Generate native CSS property identity #316. Shared paths and generated metadata semantics were audited; the final rebase was conflict-free and exact-current focused gates pass.

Scope boundaries

This PR does not claim #299's separate Monaco rendered-text defect or close #252's broader workspace/provider surface. Whole-package RSS also remains above the 750 MiB release budget. A same-package A/B shows that budget failure predates this change and the candidate changes peak/retained RSS by only +0.15%/+0.25%; AppScene#42 owns the per-process memory follow-up.

@wieslawsoltes

Copy link
Copy Markdown
Collaborator Author

Required review amendment is pushed as bc37dbbd.

  • Minimal stylesheet owners without getAttribute now initialize media state safely; this restores the existing runtime-compatibility fixture.
  • A first serialized source above the 32 MiB coalescing limit now bypasses pending replacement storage: prior pending work flushes, the source is retained once for CSSOM disconnect/reconnect semantics, and a connected owner publishes immediately. The internal stage callback returns false for this immediate path and true for bounded queued staging.
  • Focused native coverage stages a 32 MiB + framing first source against a detached retained sheet and asserts the immediate/nonqueued result, disconnected state, and null style.sheet, followed by low-memory cleanup.

Focused validation:

  • Node v24.18.1: node --test tests/RuntimeCompatibility/stylesheet-cssom.test.mjs — 8/8 pass, 55.1 ms.
  • Certification native gate: WEBSCENE_NATIVE_ENGINE_TEST_FILTER=stylesheet-mutation-performance webscene_native_engine_tests — pass; 20-cycle p95 4.386 ms, max 6.025 ms, layout delta 23, scene delta 2, heap 34,274,148 → 34,274,148 bytes, peak RSS unchanged at 105,299,968 bytes.

@wieslawsoltes
wieslawsoltes force-pushed the fix/batched-stylesheet-publication-297 branch from bc37dbb to fe4bba7 Compare September 17, 2026 19:16
@wieslawsoltes
wieslawsoltes merged commit 5f456ed into main Sep 17, 2026
0 of 7 checks passed
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.

Qualify remote workspace bootstrap, Explorer contents, and watcher refresh Reduce theme-fetch promise continuation latency during workbench startup

1 participant