Repository navigation
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.131.0-insider (commit a816e1a, 2026-07-22)
- OS Version: Arch Linux x64, kernel 7.1.4-arch1-1, Hyprland 0.56.0 (Wayland)
Steps to Reproduce:
- Get a chat working set populated: run an agent/edit session that changes several files, so the changed-files list (
.chat-editing-session-list) exists in the chat input area - Open a few files split into 3-4 editor groups
- Drag the sash between two editor groups, or between the editor area and a sidebar
The renderer main thread pegs one core and the whole UI drops to a few fps. The more editor groups, the worse; dragging the editor/sidebar boundary (which relayouts all groups at once) is the worst case. Stable on the same machine is completely fine, and so is an insiders window without a populated working set - the reason is below. Reproduces with both --ozone-platform=wayland and x11, NVIDIA driver 610.43.03, hardware acceleration confirmed via --status (gpu_compositing enabled).
A trace shows INP 668ms with 522ms input delay, Recalculate Style at 88% of bottom-up self time, and single Recalculate Style events of 218.9ms:
The forced recalcs come from the editor's own layout path: applyFontInfo writes letter-spacing, then viewLines reads geometry back (getClientRects via readHorizontalRanges / _actualReadPixelOffset), so every editor pays a forced style recalc per mousemove. That write-then-read pattern is old and normal. What's broken is the cost of each recalc: it now scales with the entire visible DOM instead of the invalidated subtree.
Cause: :has() rules
Minimal measurement, paste into the DevTools console of the workbench window. It appends a childless div directly under .monaco-workbench, writes letter-spacing on it and reads offsetHeight back. That should cost microseconds:
(()=>{const w=document.querySelector('.monaco-workbench');let p=document.getElementById('__probe');if(!p){p=document.createElement('div');p.id='__probe';p.textContent='p';p.style.cssText='position:absolute;left:-9999px;top:0';w.appendChild(p)}window.bench0=(n=8)=>{void p.offsetHeight;const t=performance.now();for(let i=0;i<n;i++){p.style.letterSpacing=i%2?'0.0001px':'0px';void p.offsetHeight}p.style.letterSpacing='';return+((performance.now()-t)/n).toFixed(3)};return'bench0() ready'})()On my real profile bench0() returns 13-16ms per write+read. On a scratch --user-data-dir with --disable-extensions it is still around 5ms. Expected is below 0.1ms.
Now delete every :has() rule from CSSOM and force one full restyle:
(()=>{const w=document.querySelector('.monaco-workbench'),reset=()=>{const d=w.style.display;w.style.display='none';void document.body.offsetHeight;w.style.display=d;void document.body.offsetHeight};let n=0;const scan=g=>{let r;try{r=g.cssRules}catch{return}for(let i=r.length-1;i>=0;i--){const x=r[i];if(x.cssRules&&x.cssRules.length)scan(x);if(/:has\(/.test(x.selectorText||'')){g.deleteRule(i);n++}}};for(const s of document.styleSheets)scan(s);reset();return n+' :has rules removed, bench0='+bench0()})()Result on my machine: bench0 goes from 14.263 / 13.387 to 0.037, roughly 375x, and sash dragging is completely smooth again.
One detail that cost me a day: deleting the rules alone changes nothing. The invalidation state sticks until you force a full restyle (that's the display toggle inside the script). I suspect this is the same effect that made #324985 "persistent".
Which rules
Per-rule contribution, measured as delete one rule, force full restyle, bench, restore the rule:
(()=>{const w=document.querySelector('.monaco-workbench'),reset=()=>{const d=w.style.display;w.style.display='none';void document.body.offsetHeight;w.style.display=d;void document.body.offsetHeight};const es=[];const scan=g=>{let r;try{r=g.cssRules}catch{return}for(let i=0;i<r.length;i++){const x=r[i];if(x.cssRules&&x.cssRules.length)scan(x);if(/:has\(/.test(x.selectorText||''))es.push({g,i,t:x.cssText,s:x.selectorText})}};for(const s of document.styleSheets)scan(s);reset();const base=bench0(6),out=[];for(const e of es){try{e.g.deleteRule(e.i)}catch{continue}reset();const ms=bench0(4);try{e.g.insertRule(e.t,e.i)}catch{}out.push({sel:e.s.slice(0,100),ms,delta:+(base-ms).toFixed(3)})}reset();out.sort((a,b)=>b.delta-a.delta);return JSON.stringify({rules:es.length,base,final:bench0(6),top:out.slice(0,10)},null,1)})()Output on my session (72 :has rules total, baseline 13.033ms):
| rule | delta (ms) |
|---|---|
.chat-editing-session-list .monaco-scrollable-element:has(.visible.scrollbar.vertical) ... (chat.css) |
9.958 |
.command-center .action-item.command-center-center:has(.compact-mode) ... (titlebar) |
0.808 |
.rendered-markdown li:has(input[type="checkbox"]) |
0.633 |
.style-override .monaco-diff-editor:has(> .diffOverview) ... |
0.483 |
.chat-confirmation-widget2 ...:has(.chat-agent-feedback-review-list):not(:has(...)) |
0.458 |
| ~65 more rules at 0.1-0.4 each | ~3 total |
So one rule accounts for 77% of it:
.interactive-session .chat-editing-session .chat-editing-session-container.show-file-icons .chat-editing-session-list .monaco-scrollable-element:has(.visible.scrollbar.vertical) .monaco-list-row .monaco-icon-label
It only bites once the chat working set list is populated, because the :has() anchor has to exist in the DOM. An empty window looks fine, a real working session doesn't. The rest is a long tail. For reference, the workbench CSS bundle went from 73 :has() occurrences on 2026-07-02 to 91 today.
How I got here (bisect trail)
I first bisected released insiders with npx @vscode/vscode-bisect --runtime desktop: last good 2be9624b8010 (2026-07-02T09:57Z), first bad 688be17ad210 (2026-07-02T15:04Z).
To make sure the boundary wasn't a subjective call, I re-ran both builds 4 times each, interleaved, each launch with a fresh empty --user-data-dir and --disable-extensions, and measured the same write/read pattern against an editor's .view-lines instead of trusting how the drag felt:
| build | forced recalc ms across 4 fresh launches | DOM element count |
|---|---|---|
good 2be9624 |
0.07 / 0.07 / 0.07 / 0.06 | 3166 / 3994 / 2361 / 2367 |
bad 688be17 |
5.79 / 4.71 / 3.35 / 4.56 | 3861 / 2885 / 1986 / 2708 |
The bad-side cost tracks the element count almost exactly (about 1.6us per element), which is what pointed at whole-document recalc rather than anything in the editor itself - and indeed none of the 19 commits in that range touch the editor, the layout code, or anything on the trace call stack.
The offender inside that range was body:has(.automation-dialog) from #323914, which is already fixed (#324985 -> #324986, #325864). Today's insiders regresses anyway because other :has() rules do the same thing as soon as their anchors exist. The chat.css rule above predates that range and never showed up in the bisect because the bisect ran on clean profiles with no chat session. Which also means this is a recurring class of regression, not a single bad rule: three instances landed in the last three weeks alone.
Suggested direction
Each of these is fixable the way #324986 fixed the dialog rules: toggle a class from the code that already knows the state. I have a PR ready that fixes the chat.css rule (the class is toggled from chatInputPart.ts, which already computes the overflow condition), replaces the remaining root-anchored :has() in floatingPanels.css and sessionsPolicyBlocked.css, and adds a stylelint check that rejects new root-anchored :has(). The long tail probably deserves an audit by the owning teams; the profiling snippet above should reproduce the ranking on any setup.
System info
CPU - 12th Gen Intel(R) Core(TM) i9-12950HX (16+8) @ 5.30 GHz
GPU - NVIDIA GeForce RTX 3080 Ti Mobile [Discrete]
GPU - Intel UHD Graphics 770 @ 1.55 GHz [Integrated]
MEMORY - 62.41 GiB
DISTRO - Arch Linux x86_64
KERNEL - Linux 7.1.4-arch1-1
WM - Hyprland 0.56.0 (Wayland)
Activity