Skip to content

editor: integrate optional editor-view GPU renderer - #336479

Draft
Alexandru Dima (alexdima) wants to merge 67 commits into
mainfrom
alexd/editor-view
Draft

Alexandru Dima (alexdima) wants to merge 67 commits into
mainfrom
alexd/editor-view

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Integrate the experimental @vscode/editor-view Rust/WASM renderer as an optional desktop distro dependency, alongside the existing DOM and TypeScript GPU renderers.

  • Add the editorView rendering mode with incremental text/token/model synchronization and measured layout/hit testing.
  • Move supported text, selections, current-line highlights, whitespace, indentation guides, line numbers, folding-control paint, and decorations to the GPU; retain DOM input, the caret and unsupported surfaces.
  • Paint the minimap's characters, selections and decorations, and the overview ruler, on auxiliary WebGPU surfaces of the same renderer. Minimap and DecorationsOverviewRuler stay mounted and keep their layout, sliders, input, fades and section headers. On WebGL2, or with a package without these APIs, they keep painting their 2D canvases.
  • Recover from GPU device loss (GPU process restart, driver update, lost WebGL2 context): the editor shows the DOM backgrounds and 2D canvases while the package rebuilds the renderer on the same canvas, then returns to GPU paint. If no renderer can be created, it falls back to DOM rendering.
  • Keep the GPU picture visible when View rebuilds the editor root's class name on focus, configuration and theme changes. Before, switching windows could leave the editor blank.
  • Detect the application-owned package at desktop startup, including ASAR builds. Hide the editorView choice when absent and validate saved editorView settings to off.
  • Restore DOM rendering and report the error if package import or initialization fails, without rewriting user settings.
  • Keep OSS/Monaco builds independent of the npm package through a host-owned type contract.
  • Mirror the full document without the prototype's 20,000-view-line cap, but send the renderer only what it reads: a line's text and tokens once it paints, measures or minimaps the line, and decorations and folding controls for the lines around the viewport, queried again when they change or scrolling leaves those lines. Opening, folding, wrapping and theme changes send the visible lines rather than the document. Typing in a 54k-line file now reaches the screen in 22–28 ms, as in DOM mode, instead of 127–209 ms.
  • Add editor.experimental.editorViewGlyphCache, registered only when the package ships. characters (the default) draws ASCII in a verified monospace font, and line numbers, one character per cell from rasters cached per character and subpixel position; runs brings back one raster per token run to compare against, until the package removes it.
  • Query decorations with the range the DOM overlays query each frame, so VS Code's one-range decoration cache serves both. Lines already sent have their gutter labels and text styles compared again only after something they depend on changes. Decoration queries take 0.38 ms a keystroke instead of 0.84 in view.ts.
  • Add editor.experimental.editorViewIncrementalRendering (on by default), registered only when the package ships. It passes incrementalRendering, which keeps the GPU surfaces' pixels between frames (microsoft/vscode-packages-internal#274); turning it off redraws every frame in full, to trace a wrong picture.
  • Draw the caret with VS Code's DOM ViewCursors above the canvas, positioned from the renderer like content widgets: a blink repaints one element instead of presenting the canvas, which costs the GPU process 22% less a blink, level with DOM mode. Block carets, smooth caret animation and every blink style behave as in DOM mode.
  • Add editor.experimental.editorViewOverscan (on by default), registered only when the package ships. The canvas draws a quarter of the viewport's height beyond it on each side and moves by a CSS transform of whole device pixels while the editor scrolls within that margin, so frames that only scroll present nothing and the compositor moves the picture. It applies with incremental rendering and a package that skips unchanged frames (microsoft/vscode-packages-internal#274), at any display scale with a package that draws on the document's device pixels (scrollAnchor), whose anchors it moves the canvas by, and at whole-number scales with older ones. Decorations that change in place are still queried for the visible range; the margin gets them on the first frame that scrolls.
  • Scroll the minimap's GPU canvas by compositor under the same conditions. It paints a quarter of the minimap's rows above and below the visible ones, and while the minimap scrolls within them Minimap only moves the canvas, by whole rows, which are whole device pixels; lines and decorations that change in those rows paint it again. A clip ends at the minimap's last whole row and its border paints the partial row below in the minimap's background, as the DOM minimap leaves it. A fast scroll now presents the minimap 0 times in 240 frames instead of 168. A minimap as tall as the editor (fill, or fit once the document no longer fits) does not scroll and paints no margin.
  • Do nothing but move the canvas on frames that only scroll: a frame in which only the vertical scroll position changed, at the same size and pixel ratio, within the canvas's margin, and whose margin has the current decorations, no longer syncs the configuration, guides, decorations, line state and viewport, nor asks the renderer for a frame. Any other view event, a forced render or a frame that did not show takes the full path.
  • Send the editorView minimap painter its decorations only when they changed, not on every scroll frame.
  • Apply the minimap section-header style to the decorations canvas's context only to measure a label (each text is measured once). Setting the font every frame cost 0.31 ms of a scroll frame in DOM and editorView mode alike with no section headers in view; Minimap: skip the section header setup when no header is in view #349719 on main now returns early in that case, and this change keeps the font unset on frames whose headers are all measured.
  • Send the renderer only the folding controls and indentation guides that changed. Every frame that queried decorations sent the folding controls of every line in its range, and every frame their guides: 87 controls and 138 guide values in each of a keystroke's two frames in view.ts, 0.17 ms a keystroke. EditorViewLineState mirrors what the renderer has for each line (inserted lines have neither, a line sent again brings its folding control and loses its guides), and frames send only the runs that differ; typing in view.ts now sends none.
  • Keep no DOM node per visible line in the content overlays while they render nothing. The renderer paints what they draw in DOM mode, so in editorView mode they usually render nothing, yet every wheel frame inserted, removed and laid out the nodes of the lines scrolling in and out. ViewOverlays.omitLinesWhileEmpty, which View asks for in editorView mode only, renders every line again once an overlay renders something (an unsupported decoration, a wrap indicator). The content layer's render now takes 0.004 instead of 0.11–0.17 ms of a scroll frame, and the divs a frame inserts and removes halve (2.67 → 1.33).
  • Measured along the way: Modern UI nests two rounded clips around the editor, which makes every frame that changes it, in either mode, draw about three render passes. That fix is a workbench change, so it moved to its own draft PR against main (workbench: don't nest rounded clips around the editor #350107); this branch adds and then reverts it, so the net diff doesn't touch workbench styles.
  • Give a window's editors one WebGPU device and glyph atlas through the package's EditorViewGroup (microsoft/vscode-packages-internal#274), created for the window on its first editor and disposed when the window closes. VS Code builds a new view for every model an editor shows, so every tab switch, peek view, diff side and notebook cell scrolled into view acquired a device and filled an atlas: splitting an editor into four created 3 devices and scrolling a notebook of 40 cells 15, and now none. A group needs WebGPU: if it fails to give an editor a renderer, the window's later editors create renderers of their own, which can fall back to WebGL2. Packages without it give every editor its own device.
  • Rasterize glyphs with the editor's font smoothing: its computed -webkit-font-smoothing, which the workbench sets from workbench.fontAliasing, passed to the window's group. The package's default, antialiased on macOS, made editorView text lighter than DOM text under VS Code's default (default, the browser's heavier smoothing). Light themes also need the package to draw each glyph in its text color's coverage (microsoft/vscode-packages-internal#281, 0.0.3); with 0.0.2 they come out heavier instead. Changing the setting reaches editorView editors after a reload.

Distro follow-up

This branch pins a distro commit that adds @vscode/editor-view 0.0.2 to npm/package.json and npm/pnpm-lock.yaml (microsoft/vscode-distro@81804ea, on the distro's alexd/editor-view branch), so product builds of this branch ship the renderer. Before merging, merge that commit into the distro's main and pin the result. The existing distro mixin copies the package into node_modules, and packaging ships it. No source dependency or product.json opt-in flag is needed. Web/server builds are not enabled by this change.

Bracket-pair guides, view zones, the minimap and overview ruler surfaces, device-loss recovery, line splices, ranged folding controls and the per-character glyph cache need the renderer APIs added in microsoft/vscode-packages-internal#269; 0.0.2 is the first release with them and with every other API this integration uses. With 0.0.1, editors that need bracket guides or view zones fall back to DOM rendering and report an error, the minimap and overview ruler keep their 2D canvases, a lost GPU device falls back to DOM rendering, the adapter sends empty placeholder lines and whole-document folding controls, and text is drawn as whole runs. Incremental rendering comes with microsoft/vscode-packages-internal#274; packages without it ignore the setting and redraw in full. Scrolling by compositor needs it too (presentNextFrame); with older packages the canvas keeps the viewport's size. At fractional display scales it also needs scrollAnchor from the same PR; without it, scrolling by compositor applies at whole-number scales only. Sharing one device and glyph atlas across a window's editors needs EditorViewGroup, also from that PR; without it every editor has its own.

Setup and behavior are documented in src/vs/editor/browser/viewParts/editorViewGpu/README.md. The editor-view package itself is not changed by this PR.

Validation

  • Monaco compile check, generated declaration check and staged-file hygiene pass.
  • Monaco editor-distro, ESM loading, webpack bundling and Chromium integration tests passed after the CI repairs. Local Firefox startup timed out before running tests; no Firefox pass is claimed.
  • 63 related Electron unit tests pass, including uncapped model synchronization, decorations and configuration; the six package-detection tests also passed. The minimap layout, dirty-row and character renderer tests and the applyTextStyleRuns tests also pass.
  • Full client type-check passes; optional-package validation also passed with the npm package physically absent.
  • Electron smoke checks verified installed WebGPU rendering, absent-package DOM rendering with no package requests, and missing-WASM error reporting with DOM recovery.
  • Detection verified against a real Electron ASAR archive.
  • DOM/GPU comparisons for tabs, Unicode and selection passed; largest measured pixel difference was 0.057%.
  • New package-side comparison regressions reproduced truncation before the cap fix (8.461% for a 30K-line document, 4.349% for the wrapped fixture), then passed after it (0.038% / 0.000%).
  • Local behavioral comparisons verify visible tails, edits/inserts/deletes/undo/redo, EOL measurements and pointer hit testing in 30,000- and 100,010-line documents, growth/shrinkage across 19,999 and 20,001 lines, and 12,000 model lines wrapping to 60,000 view lines. Ordinary large-file edits and scrolling make no full-document reloads. These comparison harness additions live separately in the editor-view package checkout and are not part of this PR.
  • Package-side integration tests compare the composited editors on screen: the GPU minimap and overview ruler are pixel-identical (0.000%) to DOM mode through decorations, selections, edits, scrolling, theme changes, blocks, sampled minimaps and every CSS color syntax. Destroying the real WebGPU device recovers to the same picture (0.031% before and after), with the minimap and ruler on the new device. Focus, blur, theme and class-option changes keep the GPU picture (at most 0.050%; 0.934% for the focus step before the fix).

For the large-document and glyph cache commits:

  • Client type-check and staged-file hygiene pass; 77 Chromium unit tests pass for the editorView decorations, guides, model-sync planner (rewritten for line splices and stale lines) and text styles, and the editor configuration.
  • 18 package-side integration tests pass, including new ones that decorations and folding controls deep in a long document follow scrolling, edits and re-sent lines; that a 100,000-line document sends the renderer only the lines it reads (20, against 100,000 before); and that text is drawn per character by default and the setting switches modes on an open editor.
  • Over the package's 46 compare fixtures, the GPU picture differs from DOM mode by 0.0165% on average at DPR 1 (0.163% at most), including a new editor.letterSpacing fixture that matches exactly.

For the decoration query and incremental rendering commits:

  • Client type-check and staged-file hygiene pass; the same 77 Chromium unit tests pass.
  • 19 package-side integration tests pass. A new one, at DPR 1 and 2, types, moves the cursor, selects, edits off screen, scrolls and changes the theme. After each step it turns the setting off and on again and requires the same canvas pixels both ways; typing redraws 1 of 12 bands. The 46 compare fixtures match DOM mode as before.

For the caret and overscan commits:

  • Client type-check and staged-file hygiene pass.
  • 20 package-side integration tests pass. A new one scrolls a WebGPU editor within its canvas's margin and past it, and checks the presents, the transform and the on-screen pixels against DOM mode, including a decoration that changed while its line was off screen in the margin (it differs by 0.87% without the first-scroll refresh). Fixtures that show the caret are now captured on screen; the 46 compare fixtures match DOM mode as before, and cursor-block now exactly (7 differing pixels before).

For the minimap commit:

  • Client type-check and staged-file hygiene pass.
  • 21 package-side integration tests pass. A new one, at DPR 1 and 2 on an editor whose minimap ends in a partial row, scrolls within the minimap canvas's margin and past it, and checks the presents, the canvas's move and the composited minimap against DOM mode. It fails when the margin lacks its decorations, when the clip shows a margin row in the partial row (7 pixels differ), and, with a translucent minimap.background, without the clip's border (69 pixels). The existing minimap test stays pixel-identical and the 46 compare fixtures match DOM mode as before.

For the scroll-frame commits (section headers, minimap decorations, moving the canvas):

  • Client type-check and staged-file hygiene pass; the minimap unit tests pass.
  • Screenshots of both compare panes' minimaps with plain, underlined, stacked and fitted section headers, at DPR 1 and 2 and three scroll positions, are identical pixel for pixel before and after the section-header change (12 pictures).
  • 21 package-side integration tests pass. The canvas-margin test now lets the editors render on their own, as while scrolling, and requires no renderer call when scrolling within the margin; it fails when the scroll-only path ignores the margin's stale decorations (0.87%) or a decoration change (0.81%). The minimap margin test fails (12%) when a decoration change does not reach the minimap painter. The 46 compare fixtures match DOM mode as before.

For the fractional-scale commit:

  • Client type-check and staged-file hygiene pass; 37 Chromium unit tests for the editorView helpers pass.
  • 22 package-side integration tests pass. A new one scrolls by odd amounts within the canvas margin at DPR 1.5, where a scroll position puts the viewport's top on half a device pixel, and compares each moved canvas with the canvas drawn there: 0 pixels differ, and nothing is presented while scrolling. The incremental and minimap-margin tests run at 1.5 too. The 46 compare fixtures match DOM mode as before.

For the folding controls and guides commit:

  • Client type-check and staged-file hygiene pass. The new EditorViewLineState unit tests cover runs of changed values, a line sent again, and lines inserted and deleted around sent ones; they fail if a line sent again keeps its guides.
  • 22 package-side integration tests pass, and the 46 compare fixtures match DOM mode exactly as before (0.0163% of pixels on average at DPR 1, 0.0290% at 2).

For the empty overlay lines commit:

  • Client type-check and staged-file hygiene pass. The new ViewOverlays unit tests check that a layer omitting empty lines keeps no nodes while its overlays render nothing, renders every line once one renders something and omits them again after, and that other layers keep a node per line; they fail if a layer that rendered lines again keeps them once they are empty.
  • Every one of the 46 compare fixtures, including the decoration fixtures that draw through the DOM overlays, differs from DOM mode exactly as before at DPR 2, and the mean is unchanged at DPR 1.

For merging main and pinning the distro:

  • Client type-check and staged-file hygiene pass after merging main. The one conflict, in InnerMinimap._renderSectionHeaders, keeps main's early return (Minimap: skip the section header setup when no header is in view #349719) and this branch's style applied only to measure a label.
  • 0.0.2, downloaded from the feed CI installs from (its integrity matches npmjs.com's), declares every member of editorViewTypes.ts in its dist/index.d.ts.

For the font smoothing commit:

  • Client type-check and staged-file hygiene pass.
  • In the package's compare harness, which now applies workbench.fontAliasing as the workbench does, a light-theme fixture of the reported lines (light-theme) had 88.1% of the DOM's ink at DPR 2 (0.146% of pixels differ). With this commit and microsoft/vscode-packages-internal#281 it differs by 0.000% at DPR 1 and 0.004% at DPR 2, with 100.0% of the ink; the other fixtures match as before or better, except two noted in that harness's README.
  • A local build that ships Git remote options (push, pull & sync) are disabled #281's release tarball has 100.1% of the DOM text's ink in Light 2026 and 100.2% in Dark 2026 (WebGPU, DPR 2, default smoothing).
  • Regression tests: the package's npm run test:compare now fails when either half is missing. Without this commit, light-theme drops to 87.5–90.1% of the DOM's ink (72.1–76.9% in vs-dark). The unit test in editorViewGpu.test.ts runs in VS Code's CI. It fails if the smoothing is read from the editor's inline style instead of what it inherits, or if CSS auto is passed as the renderer's auto.

Performance

In a VS Code dev build with a 54k-line file, GPU mode now keeps up with DOM mode: a keystroke reaches the screen in 22–28 ms (DOM 23–28, before 127–209), opening the file runs no task over 29 ms (DOM 37–54, before up to 302) and the longest task of a tab switch is 37–46 ms (DOM 34–57, before 414–500). With the decoration query commit and the package's incremental rendering, main-thread time per keystroke is close to DOM mode's: view.ts 7.9 ms against 7.6 (8.6 before), checker.ts 7.6 against 7.4, and 7.4 against 8.2 in a minified file. The package's own script time per keystroke halved in view.ts and the minified file. With the package's presenting changes (microsoft/vscode-packages-internal#274), the DOM caret and scrolling by compositor, the GPU process's CPU time, counted over all its threads, fell by about 40% per keystroke in view.ts (11.4 → 6.6 ms, against 5.5–6.9 for DOM mode in the same runs); a caret blink costs what it does in DOM mode, and a scroll frame less than DOM mode's: 1.75 against 1.97 ms without the minimap, and 1.69 against 2.42 ms with it now that the minimap scrolls by compositor too. On the renderer's main thread, the adapter's and the minimap's script time per scroll frame fell from about 0.9 to 0.2 ms in view.ts (CPU profiles), and the DOM minimap's from 0.82 to 0.22–0.30 ms. At a forced display scale of 1.5, where the canvas now scrolls by compositor too, a fast scroll presents it 0.03 times a frame instead of every frame, and the GPU process takes 0.49 instead of 0.94 ms a frame. With the package keeping line numbers as glyph rows and putting the caret's column offsets on cached cells (microsoft/vscode-packages-internal#274), and this branch sending only the folding controls and guides that changed, a keystroke's fixed work fell by about 0.3 ms of the renderer's main thread in view.ts: the package alone takes 0.014 instead of 0.033 ms for a frame that changes nothing and 0.129 instead of 0.155 ms for a typing frame. With the package giving a window's editors one device and glyph atlas, and destroying retained textures when they are discarded (microsoft/vscode-packages-internal#274), splitting an editor into four leaves the GPU process 208 instead of 308 MiB of GPU memory (DOM mode 142) and paints each new editor after 109 instead of 141 ms (DOM mode 119), and a notebook of 40 cells scrolled through holds 495 instead of 1,026 MiB (DOM mode 472). The package's docs/gpu-process-time.md and BACKLOG.md record the measurements.

Review scope

This draft includes the full existing editor-view integration branch, not only the optional-package follow-up. The default remains off; the existing on/off behavior is retained.

🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

Alexandru Dima (alexdima) and others added 25 commits July 4, 2026 20:35
Adds an opt-in integration of the @vscode/editor-view (Rust/WASM) GPU renderer,
gated by reusing editor.experimentalGpuAcceleration with a third value
'editorView' ('off'/'on' are unchanged, so nothing runs unless toggled).

- editorOptions.ts / monaco.d.ts: widen the enum to 'off' | 'on' | 'editorView'
  (default stays 'off') with an enum description.
- viewParts/editorViewGpu/editorViewGpu.ts: new ViewPart that lazily imports the
  package (the @vscode/diff loading pattern), mounts a pointer-events:none canvas
  over the editor, builds the renderer config from fontInfo + theme colors, and
  mirrors the visible lines, syncing on edit/scroll/theme/config.
- view.ts: construct EditorViewGpu only when the setting === 'editorView', append
  its canvas, and skip the DOM ViewLines.renderText work in that mode (the canvas
  is the sole text renderer) while still consuming the render flag.
- eslint.config.js: allow '@vscode/editor-view' as an editor-layer import (type
  import; loaded at runtime via resolveAmdNodeModulePath), like @vscode/diff.

Read-only proof of concept; input/selection/cursor/tokens are future work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The GPU vs DOM rendering strategy is only decided while constructing the
View, so toggling editor.experimentalGpuAcceleration had no effect until
the editor was recreated. Rebuild the view when the option changes,
preserving cursor, selection, scroll and focus by cycling the model
through the existing detach/attach paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The editorViewGpu ViewPart didn't forward the editor's content-left or the
model's tab size to @vscode/editor-view, so the GPU renderer used its own
defaults (gutterWidth 60, tabSize 4) and its text/line-numbers were offset from
the DOM editor. Plumb `layoutInfo.contentLeft` -> gutterWidth and the model's
tabSize in `_buildConfig` so the two align. Surfaced by the DOM-vs-GPU compare
harness in @vscode/editor-view.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… into editorView GPU renderer

Mirror more of the DOM gutter into the @vscode/editor-view renderer so the
compare harness matches pixel-for-pixel: pass editorLineNumber.foreground and
activeForeground, track the primary cursor's view line via onCursorStateChanged,
and pass the exact line-numbers right edge (lineNumbersLeft + lineNumbersWidth)
so digits right-align like the DOM.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…crementally

The editorViewGpu ViewPart previously forwarded only line text (so the GPU view
rendered a single foreground color) and reshipped the whole document via
setLines on every change. This:

- Forwards per-line tokens: each getViewLineData(...).tokens presentation
  (offset, ColorId resolved through TokenizationRegistry's color map, and
  bold/italic/underline/strikethrough) becomes an EditorView TokenInput, so
  syntax-highlighted content renders.
- Makes model sync incremental via a new renderer-free planner
  (EditorViewModelSync): view events map to minimal deltas — per-line setTokens
  for background tokenization, replaceLines splices for inserts/deletes/edits.
  Structure is tracked eagerly as events arrive; content is read lazily at
  present time in final coordinates, mirroring the DOM RenderedLinesCollection.
  A full setLines reload is reserved for flush / line-mapping / theme-color-map
  changes. Adds onLineMappingChanged and onTokensColorsChanged handlers.
- Adds unit tests for the planner (13 cases incl. a randomized reference
  cross-check over interleaved insert/delete/change/token edits).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The GPU renderer's margin used a placeholder darkened background, showing a
gray band in light themes where the DOM margin stays white. Send the theme's
editorGutter.background (falling back to editorBackground, matching VS Code's
own default) as the new gutterBackground config field so the margin matches
the DOM view in every theme.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The static ViewGpuContext.atlas getter throws when the GPU device hasn't
resolved yet, so ViewGpuContext.atlas?.clear() could not no-op: the
exception is raised inside the getter, before optional chaining sees a
value. A color-theme change during startup (WorkbenchThemeService init) or
a device-pixel-ratio change before the device resolved therefore threw.

Guard the backing field instead (ViewGpuContext._atlas?.clear()) at the
DPR-change and theme-change sites. The render-path callers
(canRender/canRenderDetailed) still use the throwing getter, which is
correct since they only run after the device resolves.

Add a small test pinning the getter's throwing contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ent-line

Introduce EDITOR_VIEW_GPU_CAPABILITIES in the editorViewGpu ViewPart, a static
descriptor of which editor surfaces the @vscode/editor-view (Rust/WASM) renderer
draws. view.ts consults it and, for each GPU-owned surface, no longer constructs,
mounts or ticks the corresponding DOM view part (the parallel-DOM cost this
renderer exists to remove). Load-bearing DOM stays regardless (EditContext, widget
hosts, scrollbar, and non-painting ViewLines for measurement). With only text
owned this is a behavioral no-op; flipping a flag is a one-line migration.

Flip selection + currentLine on and feed the renderer the data it needs: the full
selection set, the cursor lines and selection-empty state, focus (onFocusChanged),
and the focus-dependent selection / current-line colors, mirroring
selections.css and currentLineHighlight.ts (renderLineHighlight none/line/gutter/
all, fill vs 2px border, renderLineHighlightOnlyWhenFocus, and the
lineHighlightBorder gate via theme.value.defines).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Flip the `cursor` capability so the DOM ViewCursors view part is no
longer constructed/mounted/ticked in editorView mode, and drive the
Rust renderer's caret instead.

_cursorConfig() resolves the caret style (effectiveCursorStyle), width
(min(cursorWidth, typicalHalfwidthCharacterWidth), 0 -> 2px), height, and
per-caret foreground/background from the theme -- editorCursor.* for a
single caret, the editorMultiCursor.* palette for multiple, with the
background falling back to the foreground's opposite() exactly like the
cursor theming participant. Caret positions are tracked from
onCursorStateChanged (primary first) and mapped to the renderer's 0-based
coordinates.

Blink is host-owned: _updateBlinking() runs a 500ms WindowIntervalTimer
(mirroring ViewCursors.BLINK_INTERVAL) that toggles the caret and
repaints; the caret is shown solid on focus/cursor moves then blinks, and
hidden entirely when unfocused. smooth/phase/expand are approximated as
flat blink for now (default blink is exact). Re-armed from
onFocusChanged/onCursorStateChanged/onConfigurationChanged and disposed
with the ViewPart.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror VS Code's roundedSelection option in the editorView GPU host\nconfig and disable it in high-contrast themes, matching the DOM overlay\nbehavior.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…erer

In `editorView` mode, ViewLines no longer re-enters the DOM `renderText(...)` to
keep horizontal scrolling correct. A textless `renderTextInEditorView` keeps only
the scroll-extent (`scrollWidth`) and horizontal-reveal bookkeeping, sourcing real
line/column pixel widths from the Rust renderer through a new
`IEditorViewLineWidthProvider` (implemented by `EditorViewGpu` via
`EditorView.maxLineWidth` / `columnOffset`), instead of a monospace
`typicalHalfwidthCharacterWidth` estimate.

- Restore the DOM's whole-document-visible `_maxLineWidth = 0` reset so the
  horizontal extent can shrink (it is otherwise monotonic).
- Skip width/reveal bookkeeping until the renderer is ready rather than falling
  back to the JS estimate; the reveal compute distinguishes "not ready" (keep the
  request and retry) from "nothing to reveal" (consume it) so a reveal issued
  during startup isn't dropped.
- Unify the DOM and editorView horizontal-reveal paths onto one
  `_computeScrollLeftToRevealCore` skeleton (delegating only the per-line extent
  and RTL test) so they can't drift.
- Make `_syncModel` cheap to call several times per frame (the measurement getters
  do): add an O(1) `EditorViewModelSync.hasPendingChanges` guard so redundant
  calls skip `takePlan`'s allocations. Covered by a unit test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nderer

The Rust renderer numbered every soft-wrap continuation row because it only
knew the view-row index. Only the host owns the view-to-model mapping, so
`_buildLine` now sets a per-view-line `gutterLabel` via a new `_getGutterLabel`
that mirrors `LineNumbersOverlay._getLineRenderLineNumber`: it returns '' for a
continuation row (the view line's model column != 1), otherwise the model line
number per the `lineNumbers` option (off/on/relative/interval/custom). The
renderer draws the label verbatim (blank continuations, model number on the
first row), matching the DOM gutter.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Forward the editor whitespace mode, theme color, font-selected marker glyphs, line limit, and wrapped-line metadata to @vscode/editor-view. Gate the DOM whitespace overlay independently so other decorations remain active.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Forward visible-line guide counts, theme colors, indentation geometry, and wrapping limits to @vscode/editor-view. Capability-gate the DOM indentation overlay independently from other decorations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass the verified monospace space advance to @vscode/editor-view so fresh huge-line widths avoid synchronous canvas measurement during scrolling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Forward the view model's exact active guide range and level, including bracket-guide suppression, together with paired active theme colors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pass the editor's scroll/content width to the external renderer so current-line highlights remain correct on long horizontally scrolled lines.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Generalize the GPU line hit-test provider so the external editorView renderer can resolve click and drag coordinates without DOM text. Reuse renderer-backed widths and visible positions for related editor queries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve computed decoration paint once, synchronize retained document snapshots only on semantic changes, and preserve pointer-transparent DOM fallback for unsupported styles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve representable computed borders into ordered GPU paint while retaining whole-decoration DOM fallback for unsupported and composite CSS effects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Classify folding decorations for the retained GPU model and render their gutter pixels through @vscode/editor-view. Keep transparent DOM controls mounted so existing hover, tooltip, and click behavior remains intact.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Detect the application-owned package at desktop startup and expose the editorView choice only when installed. Keep OSS builds independent of npm types and restore DOM rendering if initialization fails.

Document distro setup and cover availability, validation, and detection failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 16, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The renderer currently loses several supported editor surfaces and misrenders large documents, view zones, auxiliary windows, and high-contrast selections.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 High severity · 10 Medium severity

Open (13)
What changed in this PR

Adds an optional desktop Rust/WASM GPU editor renderer with package detection, runtime fallback, synchronization, and tests.

Changes:

  • Adds editor-view rendering, layout, hit testing, decorations, and model synchronization.
  • Adds optional-package detection and dynamic setting availability.
  • Adds renderer-focused unit tests and documentation.
File Description
src/​vs/​platform/​product/​test/​node/​editorView.test.ts Tests package detection.
src/​vs/​platform/​product/​node/​editorView.ts Detects the optional renderer.
src/​vs/​monaco.d.ts Exposes the new mode.
src/​vs/​editor/​test/​browser/​viewParts/​editorViewGpu/​editorViewModelSync.test.ts Tests model synchronization.
src/​vs/​editor/​test/​browser/​viewParts/​editorViewGpu/​editorViewDecorations.test.ts Tests decoration conversion.
src/​vs/​editor/​test/​browser/​gpu/​viewGpuContext.test.ts Tests atlas access behavior.
src/​vs/​editor/​test/​browser/​config/​editorConfiguration.test.ts Tests option availability.
src/​vs/​editor/​contrib/​folding/​browser/​foldingDecorations.ts Relocates folding color registration.
src/​vs/​editor/​contrib/​folding/​browser/​folding.css Hides GPU-owned controls.
src/​vs/​editor/​common/​core/​editorColorRegistry.ts Registers folding-control color.
src/​vs/​editor/​common/​config/​editorOptions.ts Adds the editorView option.
src/​vs/​editor/​common/​config/​editorConfigurationSchema.ts Refreshes the dynamic schema.
src/​vs/​editor/​browser/​widget/​codeEditor/​codeEditorWidget.ts Recreates views when modes change.
src/​vs/​editor/​browser/​viewParts/​viewLines/​viewLines.ts Adds GPU measurement bookkeeping.
src/​vs/​editor/​browser/​viewParts/​editorViewGpu/​README.md Documents distro integration.
src/​vs/​editor/​browser/​viewParts/​editorViewGpu/​editorViewTypes.ts Defines the host contract.
src/​vs/​editor/​browser/​viewParts/​editorViewGpu/​editorViewModelSync.ts Plans incremental synchronization.
src/​vs/​editor/​browser/​viewParts/​editorViewGpu/​editorViewGpu.ts Implements the renderer integration.
src/​vs/​editor/​browser/​viewParts/​editorViewGpu/​editorViewDecorations.ts Resolves GPU-supported decorations.
src/​vs/​editor/​browser/​viewParts/​decorations/​decorations.ts Adds selective DOM fallback.
src/​vs/​editor/​browser/​view.ts Integrates GPU-owned view surfaces.
src/​vs/​editor/​browser/​gpu/​viewGpuContext.ts Safely clears an optional atlas.
src/​vs/​editor/​browser/​controller/​mouseTarget.ts Generalizes GPU hit testing.
src/​vs/​editor/​browser/​controller/​mouseHandler.ts Defines the hit-test contract.
src/​vs/​editor/​browser/​config/​editorConfiguration.ts Revalidates renderer availability.
src/​vs/​code/​electron-main/​main.ts Detects availability at startup.
src/​vs/​base/​common/​product.ts Adds detected product metadata.
eslint.config.js Allows the optional module reference.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/code/electron-main/main.ts Resolved
Comment thread src/vs/editor/browser/view.ts Resolved
Comment on lines +272 to +275
fontFamily: fontInfo.fontFamily,
fontSize: fontInfo.fontSize,
lineHeight: fontInfo.lineHeight,
fontLigatures,
Comment on lines +528 to +531
const lineData = this._context.viewModel.getViewLineData(viewLineNumber);
return {
text: lineData.content,
tokens: this._buildTokens(lineData.tokens, colorMap, defaultForeground),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Partly fixed in 769f54f. Inline decorations are now read as ViewLine does (including injected text), overlapping ones are combined with LineDecorationsNormalizer, and each class combination is resolved through a computed-style probe. Color (only when it wins over token colors, as in the DOM), opacity, italic and bold are applied by splitting tokens. This covers bracket-pair colorization, ghost text and color-only decorations, and is tested in microsoft/vscode-packages-internal#269. Still open: decorations whose CSS can't be painted in place of DOM text (backgrounds, borders, padding, font-size, text-decoration, pseudo-element content, e.g. inlay-hint chips) keep their token paint. They need a DOM fallback for those spans, which is the next step. Leaving this thread open until then.

🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

Preserve concrete GPU option types during isolated declaration generation and keep implementation classes out of the public API. Regenerate Monaco declarations and retain GPU hit testing through the editor distro tree shaker.

Use the Electron test runner's supported module import while retaining ASAR-aware filesystem access, and document the additional validation gates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The GPU editor sent every decoration in the document, and a folding control
for every line, whenever decorations changed, which they do on nearly every
keystroke. In a 54k-line file that cost 119 ms per keystroke, and kept the
main thread busy for seconds after opening the file while diagnostics,
folding ranges and bracket pairs arrived. Like the DOM editor, EditorViewGpu
now queries only the lines the renderer can paint plus one renderer range of
margin on each side, and queries again when decorations change or scrolling
leaves those lines. The same query finds the lines whose numbers the DOM
gutter draws, replacing a second decoration query every frame.

Folding controls for that window go through the package's new
setFoldingControls(start, controls); npm 0.0.1 still gets an array for the
whole document. Lines re-sent with replaceLines carry their folding control,
since controls are no longer re-sent for every line on each change.

Measured in a dev build on checker.ts (54k lines), GPU mode, before -> after
(DOM in brackets): main thread per keystroke 191 -> 12 ms (12); keystroke to
screen p50 127-209 -> 22 ms (22-27), with 10k find matches 263-363 -> 22 ms;
first 15 s after opening 5.0 s busy with tasks up to 300 ms -> 1.8 s, longest
task 33 ms (0.8 s, 31 ms).

How to verify: decorations, folding controls and gutter labels of the lines
on screen are unchanged; only lines farther away are no longer sent. The
package's compare integration tests (npm run test:compare) include a new one
that decorates every line of a 30,000-line document, folds every seventh,
scrolls to its start, middle and end, edits there and re-sends every visible
line. Each step matches the DOM editor, and no sync sends more than 58
decorations (31,000 before). All 45 compare fixtures are unchanged.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The GPU editor mirrored every line of the document. Opening a file, switching
to it, folding, toggling word wrap or changing the theme sent all of its
lines, and background tokenization re-sent the tokens of every line it
reached. In a 54k-line file a tab switch still blocked the UI for up to
317 ms, and the first 15 seconds after opening kept the main thread busy for
1.8 s.

The mirror now keeps the view model's line count, but a line's content only
once the renderer needs it. EditorViewModelSync turns inserts and deletes
into line splices by count (the package's new spliceLines) and marks lines
whose text or tokens changed as stale. Like the DOM ViewLines, which reads
line data at render time, the adapter sends the lines a renderer call reads
just before it: the painted range, the lines the minimap paints (runs of the
sampled lines in fit mode), and lines measured for widths, carets, pointer
positions and decoration ranges. Tokens of lines never shown are never sent.
npm 0.0.1, which has no spliceLines, gets empty lines instead.

Measured in a dev build on checker.ts (54k lines), GPU mode, before -> after
(DOM in brackets): tab switch longest task 317 -> 45 ms (41-44 ms), dropped
frames over six switches 122 -> 46 (25-43); first 15 s after opening
1.8 -> 0.8 s busy (0.8 s), longest task 33 -> 29 ms (31 ms). Typing stays at
22 ms from key to screen. Scrolling into lines not seen yet costs 0.5 ms more
per frame, as they are sent, and stays at 120 fps.

How to verify: the planner tests now check, under randomized edits, token
changes and partial sends, that a line the mirror holds is never out of date
and that the mirror equals the document once every line is sent. The
package's npm run test:compare (17 tests) passes, including a new test that
opens a 100,000-line document deep in, changes the theme and edits there,
matching the DOM editor, and measures a line never painted. It sends 20 lines
to open; the previous adapter sent 100,000. All 45 compare fixtures and the
minimap test (scrolling, edits, theme, sampled fit mode) are unchanged.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`editor.experimental.editorViewGlyphCache` ('runs' by default) is sent to
the editorView renderer as `glyphCache` and applies as soon as it changes.
With 'characters', ASCII text in a verified monospace font, and line
numbers, are drawn one character per cell from rasters cached per
character and subpixel position instead of one raster per token run, so
typing and scrolling stop rasterizing once those characters were seen.

The setting exists to choose between the two with data (pixel fidelity to
the DOM editor and frame cost) and goes away once one is chosen. Like the
`editorView` value of `editor.experimentalGpuAcceleration`, it is
registered only in builds that ship @vscode/editor-view. It is not an
editor option, so the Monaco API does not change.

How to verify: in vscode-editor-view, `npm run test:compare` includes a
test that passes the option to a standalone editor and checks that the
renderer draws one glyph per character, then one per run, then one per
character again as the option changes. Manually: with
"editor.experimentalGpuAcceleration": "editorView", set
"editor.experimental.editorViewGlyphCache": "characters"; the open editor
switches without reopening and text keeps its look.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`editor.experimental.editorViewGlyphCache` now defaults to 'characters',
matching @vscode/editor-view's new default: ASCII text in a verified
monospace font, and line numbers, are drawn one character per cell from
rasters cached per character and subpixel position. Builds that do not
ship the package do not register the setting, so the adapter also uses
'characters' unless the value is 'runs'. 'runs' remains to compare
against and goes away with the package option.

Against runs, the renderer is closer to the DOM editor on 27-28 of the
package's 46 pixel comparisons and further on none, and it now matches
the DOM with `editor.letterSpacing`. In checker.ts (54k lines), a
keystroke costs 13.6 ms of main-thread work instead of 15.8 and a tab
switch 169 ms instead of 221; scrolling back over code already drawn
costs 0.1-0.2 ms a frame more.

How to verify: in vscode-editor-view, `npm run test:compare` includes
"ASCII text is drawn per character by default, and the glyph cache
setting applies as it changes": it opens an editor without the setting
and finds one glyph per character, then one per run with 'runs', then
characters again. Manually: with
"editor.experimentalGpuAcceleration": "editorView", text looks as before;
"editor.experimental.editorViewGlyphCache": "runs" switches the open
editor back to whole runs.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve the conflict in mouseTarget.ts: main now handles clicks on empty lines
for both renderers before the GPU-only hit testing (#349617), while this branch
renamed `viewLinesGpu` to `viewLineHitTestProvider` so that editorView can
answer hit tests too. Keep main's code and use the provider in the GPU block
after it.

main's #349182 also changes the gutter without conflicting: a click left of the
text places the cursor unless it lands on a `.cldr` line decoration, and folding
chevrons take clicks only through a centered `::after`. editorView keeps
`LinesDecorationsOverlay` mounted and its folding controls as transparent DOM
elements, so its gutter behaves like the DOM editor's.

How to verify: `git diff M^2 M -- src/vs/editor/browser/controller/mouseTarget.ts`,
where M is this merge, shows only this branch's rename. In the editor-view
package's compare harness, the DOM and GPU editors give the same hit targets
beside and on a chevron, place the cursor and fold the same way on real clicks,
and both show the text cursor over the gutter.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
VS Code's ViewModelDecorations caches the decorations of one range, the
one the DOM overlays query each frame (`ViewportData.visibleRange`). The
editorView adapter queried others: its renderer range for inline styles,
line by line, and a wider window for the decorations it sends, so a
keystroke computed the viewport's decorations several times.

- When decorations change where the view already is (typing, find
  matches, diagnostics), the adapter queries exactly the visible range,
  which the cache then also serves to the DOM overlays. Scrolling away
  from the lines it has still queries a wider window.
- A line's inline styles come from that query and the line's own
  injected text, instead of a viewport query per line.
- Gutter labels and text styles of lines already sent are compared
  again only after something they depend on changes (an edit, the
  cursor, decorations, the theme or options), and on lines newly in the
  renderer's range.

Decoration queries took 0.38 ms a keystroke instead of 0.84 in view.ts,
0.08 instead of 0.18 in jquery-4.0.0.min.ts and 0.03 instead of 0.24 in
checker.ts (CPU profiles of 40 keystrokes, two runs each).

How to verify: in vscode-editor-view, `npm run test:compare` covers
inline decorations as they change, gutter labels following edits, the
cursor and the lineNumbers option, high-contrast selected text, and
decorations deep in a long document; its 19 tests pass, and the 46
compare fixtures match the DOM as before. Manually: with
"editor.experimentalGpuAcceleration": "editorView", find matches and
relative line numbers follow typing as in the DOM editor.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`editor.experimental.editorViewIncrementalRendering` (on by default) is
sent to the editorView renderer as `incrementalRendering` and applies as
soon as it changes. With it, the renderer keeps the pixels of the editor,
minimap, overview ruler and scrollbar canvases between frames and redraws
only the bands whose content changed; off, it redraws every frame in
full. Packages up to 0.0.1 ignore it and always redraw in full.

It exists so that a wrong picture can be traced to incremental rendering
(turn it off and see whether the problem stays) and to compare the two.
Like the glyph cache setting, it is registered only in builds that ship
@vscode/editor-view, and it is not an editor option, so the Monaco API
does not change.

How to verify: in vscode-editor-view, `npm run test:compare` includes
"incremental frames show what full redraws show, and redraw only what
changed": after each of typing, moving the cursor, selecting, editing
off screen, scrolling and a theme change, it turns the setting off and
on again in a standalone editor and requires the same canvas pixels both
ways. Manually: with "editor.experimentalGpuAcceleration": "editorView",
set "editor.experimental.editorViewIncrementalRendering": false; the open
editor keeps its look and redraws in full from then on.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With `editor.experimentalGpuAcceleration: editorView`, the renderer drew
the caret and the adapter presented the whole editor canvas for every
blink. Presenting costs the GPU process and the compositor a frame
however little changes, while toggling a DOM caret over the canvas only
repaints that element. The capability `cursor` is now false: View
mounts the DOM ViewCursors above the canvas, as for the other DOM
layers, and the adapter neither sends carets nor runs its blink timer.
Carets take their positions from the renderer through RenderingContext,
as content widgets do; block carets, smooth caret animation and the
smooth/phase/expand blink styles now behave exactly as in DOM mode.

In view.ts (three rotating runs of each), GPU process CPU per blink
fell 22% (4.98 -> 3.87 ms), level with the DOM editor (4.17 ms);
keystrokes and scrolling did not change (7.89 / 7.43 and 2.28 / 2.28
ms).

How to verify: in vscode-editor-view (its draft PR #274 captures
fixtures that show the caret on screen, as the DOM pane is captured),
`npm run test:compare` passes and `npm run compare` reports the same
differences as before for 45 fixtures; cursor-block drops from 7
differing pixels to none. Manually: in editorView mode, the caret
blinks, moves while typing and follows multi-cursor and block styles
as in DOM mode.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With `editor.experimentalGpuAcceleration: editorView`, every scroll frame
presented the editor canvas, drawn again at the new position. The canvas
now draws a quarter of the viewport's height above and below it and keeps
its place while the viewport stays within that margin: the adapter moves
it with a CSS transform of whole device pixels, so a frame that only
scrolls changes nothing the renderer draws, the renderer presents
nothing, and the compositor moves the picture. Once the viewport leaves
the canvas, the canvas moves to leave the whole margin ahead of the
scroll and draws only the rows new to it.

- `editor.experimental.editorViewOverscan` (on by default, registered
  only in builds that ship @vscode/editor-view) turns it off. It also
  needs WebGPU with incremental rendering, an integer display scale
  (otherwise whole CSS pixels are not whole device pixels, and the
  compositor would resample the picture) and a renderer that skips
  unchanged frames (`presentNextFrame`).
- The renderer gets lines, line state and guides for the canvas's range.
- Decorations that change in place are still queried for the visible
  range, whose cache the DOM overlays share; the margin, off screen until
  a frame scrolls, gets them on the first such frame.

In view.ts (three alternating runs each), 240 frames of wheel scrolling
presented the editor canvas 8-9 times at 57 px a frame and never at 19 px,
instead of 240 times. Without the minimap, GPU process time per frame
fell 17% (2.12 -> 1.75 ms; 1.86 -> 1.63 ms at 19 px), below the DOM
editor (1.97 and 1.99 ms). With it, scrolling costs about what the DOM
editor's does (2.10 against 2.13 ms): every scroll frame is a compositor
frame of about 1.6 ms in both editors, and the minimap still presents in
most of them. Typing costs the same as before.

How to verify: in vscode-editor-view (draft PR #274),
`npm run test:compare` includes "scrolling within the canvas margin moves
the picture without presenting it": it scrolls a VS Code editor on WebGPU
within the margin and past it, and checks the presents, the transform and
the on-screen pixels against the DOM editor, including a decoration that
changed while its line was in the margin; without the first-scroll
refresh, that line differs by 0.87%. The other compare tests and the 46
fixtures pass unchanged. Manually: scroll an editorView editor; it looks
the same, and "editor.experimental.editorViewOverscan": false restores
drawing every frame.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With `editor.experimentalGpuAcceleration: editorView`, the minimap's GPU
canvas presented in most frames of a scroll (168 of 240 at 57 px a frame
in view.ts): the minimap painted again whenever its first line changed.
Under the conditions in which the editor canvas scrolls by compositor
(`editor.experimental.editorViewOverscan`, WebGPU with incremental
rendering, an integer display scale), the minimap's canvas now paints a
quarter of the minimap's rows above and below the visible ones, and while
the minimap scrolls within them `Minimap` only moves the canvas, by whole
rows, which are whole device pixels. It paints again when the visible
rows leave the painted ones, leaving the whole margin ahead of the
scroll, or when lines or decorations in the painted rows change.

- A clip ends at the minimap's last whole row, and its border paints the
  partial row below in the minimap's background, as the DOM minimap
  leaves it, so no row of the margin shows there.
- A minimap as tall as the editor (`fill`, or `fit` once the document no
  longer fits) shows all its lines, never scrolls and paints no margin.
- The painter reports whether the minimap may overscan
  (`IMinimapPainter.canOverscan`); `EditorViewGpu` answers it and places
  its own canvas with the same conditions. The 2D minimap is unchanged.

In view.ts (six alternating runs each, on a busy machine), the minimap
now presents 0 times in 240 frames of wheel scrolling, instead of 168 at
57 px a frame and 64 at 19 px. A fast scroll frame costs the GPU process
21% less (2.14 -> 1.69 ms), 30% less than the DOM editor's (2.42 ms).
Slow scrolling (2.09 -> 1.97 ms) and typing (6.92 -> 7.32 ms) moved within
the runs' noise; traces show the same work per presented frame. An edit
builds the minimap's frame for 1.5 times the rows, about 0.3 ms more of
the renderer's main thread a keystroke.

How to verify: in vscode-editor-view (draft PR #274),
`npm run test:compare` includes "scrolling within the minimap margin
moves its picture without painting it": at device pixel ratios 1 and 2,
on an editor whose minimap ends in a partial row, it scrolls within the
minimap canvas's margin and past it, and checks the presents, the
canvas's move and the composited minimap against the DOM minimap. It
fails when the margin lacks its decorations, when the clip shows a margin
row in the partial row (7 pixels differ), and, with a translucent
`minimap.background`, without the border (69 pixels). The existing
minimap test stays pixel-identical, and the other compare tests and the
46 fixtures pass unchanged. Manually: scroll an editorView editor with
the minimap on; the minimap's second canvas moves by a transform and
looks the same, and "editor.experimental.editorViewOverscan": false
paints only the visible rows again.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Every minimap frame that repaints the decorations layer (every scroll
frame, and frames whose selections or decorations change) saved the
decorations canvas's 2D context and set its font and letter spacing to
measure section-header labels, before looking for any header to draw.
Setting a context's font is costly: in a CPU profile of wheel scrolling
in view.ts, which has no section headers, it took 0.31 ms of the
renderer's main thread per frame, in DOM and editorView mode alike.

Fitted label texts are cached per text, so labels are measured once.
The context is now styled when the first label of a frame is measured,
and restored only then; drawing styles its own context as before.

In view.ts (CPU profiles of 120 frames of wheel scrolling, two rounds),
the minimap's script time per frame fell from 0.82 to 0.22-0.30 ms in
DOM mode; with the next commit, from 0.36-0.57 to 0.08-0.10 ms in
editorView mode.

How to verify: screenshots of both compare panes' minimaps (DOM and
editorView, device pixel ratios 1 and 2), with plain, underlined,
stacked and fitted section headers, at three scroll positions, are
identical pixel for pixel before and after (12 pictures; with
`minimap.showSlider: always`, so the slider's fade does not differ). The
minimap unit tests pass. Manually: add `// MARK: Section` comments to a
file; the minimap shows the labels as before.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`Minimap` gave the editorView minimap painter the decorations of the
lines it paints whenever the 2D decorations layer had to repaint, which
every scroll frame asks for, so every scroll frame queried, mapped and
compared the minimap decorations of all painted lines, though they only
change with the decorations or with the painted lines (which invalidate
the painter, and then decorations are sent as before). The painter now
gets them when decorations changed since it last got them, or when it is
invalidated. In a CPU profile of wheel scrolling in view.ts this was
0.04 ms of the renderer's main thread per frame.

How to verify: in vscode-editor-view (draft PR #274), `npm run test:compare`
includes "scrolling within the minimap margin moves its picture without
painting it", whose "decorated every seventh line" step changes only
decorations; it fails (12% of the minimap differs from DOM mode) when a
decoration change does not reach the painter. Manually: add and remove
find matches while scrolling; the minimap shows them as in DOM mode.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With `editor.experimentalGpuAcceleration: editorView` and scrolling by
compositor, a frame that only scrolls the editor within the canvas's
margin draws nothing new and presents nothing, but the adapter still
synced the renderer on every such frame: the configuration, indentation
and bracket guides, decorations, line state and viewport, and the
renderer built and hashed its scene to find that nothing changed. In a
CPU profile of wheel scrolling in view.ts that was 0.37 ms of the
renderer's main thread per frame.

The adapter now notes whether anything besides the vertical scroll
position changed since the last frame drew: any view event other than
a scroll event that changes only `scrollTop`, a forced render
(`render(true)`), and a frame that did not show (the surface was
unavailable). A frame without such a change, at the same size and pixel
ratio, whose viewport stays within the canvas's margin, and whose
margin has the current decorations, only sets the canvas's transform.
Every other frame draws as before.

In view.ts (CPU profiles of 120 frames of wheel scrolling, two rounds),
the adapter's script time per frame fell from 0.38-0.61 to 0.13-0.14 ms;
the remainder is the frames that move the canvas and VS Code's caret and
line width queries. With the previous two commits, the editor parts'
script time per scroll frame in editorView mode is about 1.2 ms less.

How to verify: in vscode-editor-view (draft PR #274), `npm run test:compare`
includes "scrolling within the canvas margin moves the picture without
presenting it", which now lets the editors render on their own, as they
do while scrolling, and counts the renderer's frames: scrolling within
the margin calls the renderer 0 times, and the on-screen pixels match
DOM mode. It fails when the fast path ignores the margin's stale
decorations (0.87% of the editor differs once they scroll into view) or
other view events (0.81% differs after a decoration changes in place).
Manually: scroll an editorView editor; it looks the same, and edits,
selections and decoration changes while scrolling show as before.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With Modern UI (the default), the editor card in editorBorder.css rounds and clips the editor
part, and floatingPanels.css also rounds the part's `.content`, inside it. Chromium applies one
rounded clip per draw quad, in the shader. For nested rounded clips, Blink gives the outer clip
render surfaces ("Nested rounded corner clips need to force render surfaces for clips other than
the leaf ones", property_tree_manager.cc). So every frame that changes the editor drew about
three render passes, two of them offscreen copies of the editor, instead of handing the editor's
layers to CoreAnimation as they are.

Now only the card clips; `.content` inside it keeps a square clip. Its corners follow the card's
inner edge (7 px: the 8 px radius less the 1 px border) instead of an 8 px arc 1 px inside it,
which also removes a faint crescent of card background at each corner.

Measured in one instance, alternating the old and the new rule (traced thread CPU time, 8-12
pairs, every pair agreeing):
- scrolling, editorView: GPU process 1.08 -> 0.44 ms per frame; render passes drawn 2.9 -> 0
- scrolling, DOM editor: 1.50 -> 0.97 ms per frame; 3.0 -> 0
- typing, editorView: 2.93 -> 2.20 ms per keystroke; 2.8 -> 0
The renderer runs the same tasks per frame. Its main thread's CPU time varied between runs
(+0.0 to +0.5 ms per scroll frame), with constant-work tasks such as IPC dispatch slower by the
same ~10%, which points at a lower clock rather than more work. Removing every rounded clip
saves the same in the GPU process, so the card's own clip costs nothing there.

How to verify:
- Scroll an editor under a trace of the `viz` category: with this change frames that scroll draw
  no `DirectRenderer::DrawRenderPass`; with the old rule there are about three per frame.
- Screenshots of the editor part before and after differ in 90 of 4.45 M device pixels at
  DPR 2, all on the four corner arcs, by at most 10/255 per channel.
- `./scripts/test.sh --run src/vs/workbench/test/browser/parts/chat/chatHostPart.test.ts`

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Scrolling by compositor applied at whole-number display scales only. The
renderer drew content where `line top - scroll top` put it, which at 1.5 falls
on half device pixels for odd scroll positions, so a frame drawn at one
position and moved by whole device pixels showed content half a pixel from
where drawing it there puts it. Renderers that have `scrollAnchor`
(microsoft/vscode-packages-internal#274) draw content on the document's device
pixels instead. With them the adapter scrolls the canvas, and the minimap, by
compositor at any scale, and moves the canvas by the difference of the
renderer's anchors for the two scroll positions, so it rounds as the renderer
does. Older renderers keep whole-number scales only.

At a forced scale of 1.5, wheel scrolling view.ts 57 px a frame (one instance
alternating the setting, 8 pairs, every pair agreeing): the editor canvas
presents 0.03 times a frame instead of every frame, and the GPU process's
traced CPU time a frame falls from 0.94 to 0.49 ms.

How to verify:
- In @vscode/editor-view (#274), `VSCODE_OUT=<vscode>/out npm run test:compare`:
  "at a fractional pixel ratio, the canvas moved within its margin shows what
  drawing it there shows" scrolls by odd amounts at 1.5 and compares the moved
  canvas with one drawn there, pixel for pixel; the minimap and incremental
  tests also run at 1.5 now.
- At whole-number scales the anchors are the rounded products, as the offset
  was before, so nothing changes there.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 36fd52c. The fix moves to its own draft PR against
main: it isn't editor-view work, it changes Modern UI for every editor, and
main has since changed the same corners ("Fix floating editor corner
alignment", #349847) and added tests that check `.content`'s own radius,
which this branch's version of the rule fails. The new PR updates those tests.

How to verify: `git diff 36fd52c~1 HEAD -- src/vs/workbench/contrib/modernUI/browser/media/editorBorder.css`
prints nothing.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ides that changed

Every frame that queried decorations sent the folding controls of every
line in its range, and every frame sent their indentation guides, though
they rarely change: typing in view.ts sent 87 folding controls and 138
guide values in each of a keystroke's two frames, which a CPU profile put
at 0.107 ms (folding controls) and 0.060 ms (guides) of the renderer's
main thread a keystroke, mostly serializing them into WASM.

`EditorViewLineState` now mirrors what the renderer holds for each line:
inserted lines have neither, a line sent again brings its folding control
and loses its guides, and sending records the values. A frame sends only
the runs of lines whose values differ. Typing in view.ts now sends no
folding control and a guide in 1 of 40 keystrokes; the guides are still
computed every frame.

How to verify:
- `./scripts/test.sh --run src/vs/editor/test/browser/viewParts/editorViewGpu/editorViewLineState.test.ts`:
  runs of changed values, a line sent again, and lines inserted and
  deleted around sent ones. It fails if a line sent again keeps its guides.
- With `editor.experimentalGpuAcceleration: editorView`, fold and unfold,
  type on indented lines, insert and delete lines and move the cursor
  between blocks: folding controls and (active) guides follow as before.
  The package's DOM compare suite is unchanged (0.0163% of pixels differ
  at a scale of 1, 0.0290% at 2).

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The renderer paints what the content overlays draw in the DOM editor
(selections, current line, guides, whitespace, supported decorations), so
in GPU mode those overlays usually render nothing at all, but the layer
still kept a DOM node per visible line: every wheel frame inserted and
removed the nodes of the lines scrolling in and out, and laid them out.
A layer can now omit its lines while every overlay renders nothing on
every visible line (`ViewOverlays.omitLinesWhileEmpty`), and render them
all again once one renders something; `View` asks for it for the content
overlays in editorView mode only.

Wheel scrolling view.ts in GPU mode (one run each, a busy machine): the
content layer's render took 0.004 ms a frame instead of 0.11-0.17 ms (CPU
profiles), divs inserted and removed fell from 2.67 to 1.33 a frame, and
Blink painted 2.4 times a frame instead of 3.4 (invalidation traces).

How to verify:
- `./scripts/test.sh --run src/vs/editor/test/browser/view/viewOverlays.test.ts`:
  a layer that omits empty lines keeps no nodes while its overlays render
  nothing, renders every line once one renders something, and omits them
  again after; other layers keep a node per line. It fails if a layer
  that rendered lines again doesn't drop them once they are empty.
- With `editor.experimentalGpuAcceleration: editorView`, decorations the
  GPU does not paint (an unsupported class) and the word wrap indicator
  (`editor.wordWrap: on` with `editor.wordWrapIndicator`) still show, and
  disappear when they go away. DOM mode and the margin are unchanged.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Monaco editor build (`gulp editor-distro`) failed on "send the
editorView renderer only the folding controls and guides that changed":
`{ type: 'setIndentGuides', ...run }` is not assignable to
`ModelDeltaInput`. Its tree shaker removes interface members that nothing
reads by name, and `IIndentGuidesRun`'s fields were only spread, so the
shaken type had none. The adapter now passes them by name; the client
type check never saw the error, as it compiles the unshaken sources.

How to verify:
- `pnpm run gulp editor-distro` passes (it failed in the "Monaco Editor"
  check of this PR).
- `npm run typecheck-client` and
  `./scripts/test.sh --run src/vs/editor/test/browser/viewParts/editorViewGpu/editorViewLineState.test.ts`
  pass; the delta sent is the same object as before.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tlas

VS Code builds a new view for every model an editor shows, and every
view's `EditorViewGpu` created an `EditorView` with a WebGPU device and a
glyph atlas of its own: each tab switch, peek view, diff side and notebook
cell scrolled into view acquired a device. The adapter now creates one
`EditorViewGroup` (microsoft/vscode-packages-internal#274) per window on
its first editor, passes it to every editor of the window, and disposes
it when the window closes. The editors draw with one set of pipelines,
their frames of a task are submitted at once, a glyph rasterized for one
is drawn by all, and after a device loss they recover onto one new
device.

A group needs WebGPU. If it fails to give an editor a renderer, that
editor and the window's later ones create renderers of their own, which
can fall back to WebGL2, while its earlier editors keep the group.
Packages without `EditorViewGroup` (npm 0.0.1) give every editor its own
device, as before. The README describes it.

Measured with the package's group (two instances each, medians): four
editor groups create no device instead of 3, and a split's new editor
paints after 109 instead of 141 ms (the DOM editor 119); scrolling a
notebook of 40 cells creates no device instead of 15, and with the
package's release of discarded textures holds 495 instead of 1,026 MiB of
GPU memory (the DOM editor 472).

How to verify:
- `npm run typecheck-client` and `npm run oxlint` on the changed files.
- With microsoft/vscode-packages-internal#274 hot-linked, the editor-view
  package's `npm run test:compare` (22 tests in VS Code's editor,
  including device loss and the canvas and minimap margins) passes.
- With `editor.experimentalGpuAcceleration: editorView`, split an editor:
  the new editor requests no WebGPU device (wrap
  `GPUAdapter.prototype.requestDevice` in the developer tools).

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
One conflict, in InnerMinimap._renderSectionHeaders (minimap.ts): main's
#349719 now gets the section header decorations first and returns when
there are none, and this branch applies the label style only when a label
is measured. Both are kept. Neither side's lines at the conflict remain:
each would declare `decorations` or `fitWidth` a second time.

How to verify:
- `git show --remerge-diff` of this commit shows only that resolution.
- `npm run typecheck-client` passes.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Product builds of this branch now ship the renderer. The pinned distro
commit, 81804ea8 on vscode-distro's alexd/editor-view branch, adds
@vscode/editor-view 0.0.2 to npm/package.json on top of 07cc7676, the
distro commit main pins. The distro mixin copies it into node_modules and
packaging ships it, so `editor.experimentalGpuAcceleration` offers
`editorView` in those builds.

0.0.2 is the first release with every API this integration uses, so the
README names it instead of 0.0.1.

Before merging this into main, merge that distro commit into the distro's
main and pin the result: main shouldn't build from a distro branch.

How to verify:
- The distro commit changes only npm/package.json and npm/pnpm-lock.yaml,
  adding @vscode/editor-view 0.0.2:
  microsoft/vscode-distro@81804ea
- Every member of editorViewTypes.ts is declared in 0.0.2's
  dist/index.d.ts.
- A product build of this branch logs "Mixing in distro npm dependencies"
  and ships @vscode/editor-view; in it, `editor.experimentalGpuAcceleration`
  offers `editorView`.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The package rasterized glyphs `antialiased` on macOS, its `fontSmoothing`
default, but the workbench smooths editor text as `workbench.fontAliasing`
says, and its default, `default`, keeps the browser's heavier smoothing. So
editorView text looked lighter than DOM text: in the package's `light-theme`
compare fixture, the GPU pane had 88.1% of the DOM pane's ink.

Read the editor's computed `-webkit-font-smoothing` when its window's group
is created and pass it as the group's `fontSmoothing`, or a view's own when
there is no group; the workbench's smoothing applies to all of a window's
editors. With @vscode/editor-view 0.0.3, which draws each glyph in its text
color's coverage (microsoft/vscode-packages-internal#281), the fixture
matches DOM text. With 0.0.2 dark themes match, but light themes come out
heavier (113.5% of the DOM's ink), since 0.0.2 draws every glyph in white.

Changing `workbench.fontAliasing`, or moving a window between displays with
`auto`, reaches editorView editors after the window reloads.

How to verify:
- In the package's compare harness, with this out/ and the package at
  microsoft/vscode-packages-internal#281, `npm run compare -- light-theme
  --dpr=2` differs by 0.004% and the GPU pane has 100.0% of the DOM pane's
  ink. Without this commit it differs by 0.146%, with 88.1% of the ink.
- In a build with `editor.experimentalGpuAcceleration` set to `editorView`,
  text in a light theme weighs the same with the setting on and off.
- `npm run typecheck-client` passes.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`editorViewFontSmoothing` has to read the smoothing the editor inherits
from the workbench, which sets `workbench.fontAliasing` on its container,
and pass the browser's own smoothing (CSS `auto`) as the renderer's
`default`: the renderer's `auto` is antialiased on macOS, and made
editorView text lighter than DOM text. @vscode/editor-view's compare tests
check the text's weight end to end, but VS Code's CI doesn't run them.

How to verify:
- `node test/unit/browser/index.js --browser chromium --run
  src/vs/editor/test/browser/viewParts/editorViewGpu/editorViewGpu.test.ts`
  passes, and with `--browser webkit`.
- It fails when `editorViewFontSmoothing` returns the computed value as is
  (`auto` instead of `default`), or reads the element's inline style instead
  of its computed style (`default` for every smoothing).

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

2 participants