Skip to content

Cache resolved CSS variables#286838

Merged
Tyriar merged 1 commit intomainfrom
tyriar/286833
Jan 9, 2026
Merged

Cache resolved CSS variables#286838
Tyriar merged 1 commit intomainfrom
tyriar/286833

Conversation

@Tyriar
Copy link
Copy Markdown
Contributor

@Tyriar Tyriar commented Jan 9, 2026

Fixes #286833

@Tyriar Tyriar added this to the January 2026 milestone Jan 9, 2026
@Tyriar Tyriar self-assigned this Jan 9, 2026
Copilot AI review requested due to automatic review settings January 9, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds caching for resolved CSS variables to improve performance by avoiding repeated DOM manipulations and computed style queries. The cache stores the resolved string values of CSS variables that are looked up via getComputedStyle.

Key changes:

  • Added a _cssVariableCache map to store resolved CSS variable values
  • Modified resolveCssVariable method to check the cache before performing expensive DOM operations

private _dummyElement: HTMLSpanElement;

private _ruleCache: Map</* className */string, CSSStyleRule[]> = new Map();
private _cssVariableCache: Map</* variableName */string, /* value */string> = new Map();
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CSS variable cache is never invalidated when themes change. CSS variables can have different values depending on the active theme. Since DecorationCssRuleExtractor is a static singleton (line 43 in viewGpuContext.ts), the cache will persist across theme changes and return stale values.

Similar to how TextureAtlas.clear() is called on theme changes (see atlas/textureAtlas.ts line 71-75), this cache should also be cleared when the theme changes. Consider adding a clear method to DecorationCssRuleExtractor and calling it when the theme changes, or subscribing to theme change events within the class itself.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

@rzhao271 I've opened a new pull request, #286840, to work on those changes. Once the pull request is ready, I'll request review from you.

@Tyriar Tyriar merged commit 8fdbf92 into main Jan 9, 2026
27 of 28 checks passed
@Tyriar Tyriar deleted the tyriar/286833 branch January 9, 2026 22:42
eli-w-king pushed a commit that referenced this pull request Jan 14, 2026
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Feb 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor GPU: Regression when resolving CSS variables

4 participants