Repository navigation
WebGPU: Fix editor GPU alpha, scrolling, cache lifetime, and atlas allocation - #340836
Davlatjon Sh (dalisoft) wants to merge 5 commits into
Conversation
Correct premultiplied canvas alpha and glyph instance counts. Keep scroll offsets in the viewport coordinate system, invalidate stale cached rows, preserve fractional font sizes, and dispose replaced rendering resources. Allocate atlas layers and glyph metadata according to page usage, with regression and WebGPU pixel tests.
Verification details and reproducible controlsAI-assisted implementation and automated investigation by OpenAI Codex under Davlatjon Sh (@dalisoft)'s direction. The immutable evidence records the source revision, dependency versions, scripts, logs, observations, screenshots and hashes. The macOS test builds were prepared before opening this PR. Why the faint text is a blend defectFor straight shader output The production WGSL readback test uses a texel Why the large-file disappearance is a coordinate defectThe retained integrated control reaches scrollTop 1,199,619 with The before screenshot shows the gutter around line 50,000 and an empty text area, with zero content ink pixels and no DOM text fallback. The fixed capture has 29,508 text pixels in that region. Mock-based tests additionally assert the actual uniform and cell coordinates for both strategies, then return to a small scroll offset to check origin reset. The full-file strategy invalidates cached coordinates when the origin changes; the real 60,000-line path selects the viewport strategy. Draw counts, cache contents and lifetime
The controls isolate original production behavior in compiled output, restore every modified file in Atlas growth and memory interpretationCapacity changes replace both allocations through registered At 2× density, one RGBA8 page is macOS package proof and remaining manual checkThe Apple Silicon application was built on The packaged workbench then passed on an Apple WebGPU adapter with WebGPU enabled, actual GPU text at the top and near line 50,000, empty DOM fallback and no captured GPU/page errors. Its bounded upper content region excludes the gutter and notifications; content pixel counts are 11,642 and 13,421. Native captures and successful smoke run are retained. Intel packaging also succeeds, with 52 passing tests / three pending. Its GPU readback skips because no adapter is available; the packaged GPU-on check also fails on that CI runner. Those failures are retained rather than described as rendering passes. The contributor selected Apple Silicon, which is the downloadable build. The historical hosted Apple memory run, tied to The original Code OSS source-package task hit an unrelated Copilot dependency filter: the SDK was removed before the build attempted to prepare its shim. The fork workflow retains that dependency for the source-built extension only and records the exact packaging patch. This adjustment is outside the source PR. The source editor/client files remain the committed revision. Latest controlled local Mac observation — October 10, 2026The contributor's M1 Max (64 GB unified memory / 32-core GPU), running macOS 27.0.1, was tested with a Code OSS 1.142.0 package whose minified workbench was locally rebuilt with the memory follow-up. The same local configuration folder and matching settings were used in two fresh profiles, differing in editor GPU acceleration. The instances ran concurrently and were sampled approximately 55 seconds after launch.
These are macOS The package's retained The contributor reports glyphs and scrolling working and enjoying the local build. It may feel faster, but general OS sluggishness after the macOS upgrade makes that impression inconclusive. No benchmarked speedup is claimed. Remaining manual checks include longer workloads, display scaling, cursor/selection alignment, split/resized editors and whole-app memory accounting. The historical diagnosis guide remains available. This PR is ready for maintainer review; whole-app memory acceptance and broader manual checks remain open. |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes core GPU rendering and resource lifetime behavior while broader visual and memory validation remains open.
2 open findings
What changed in this PR
Fixes correctness, lifecycle, and allocation defects in the experimental editor GPU renderer.
Changes:
- Corrects alpha blending, large-scroll coordinates, draw counts, and fractional font sizing.
- Improves cache invalidation and GPU resource disposal.
- Dynamically sizes atlas storage and adds focused regression tests.
| File | Description |
|---|---|
src/vs/editor/test/browser/gpu/renderStrategy.test.ts |
Tests strategy drawing, scrolling, caching, and disposal. |
src/vs/editor/test/browser/gpu/gpuRendering.test.ts |
Tests real WebGPU alpha and atlas resizing. |
src/vs/editor/test/browser/gpu/glyphRasterizer.test.ts |
Tests fractional font metrics. |
src/vs/editor/test/browser/gpu/atlas/gpuAtlasStorage.test.ts |
Tests atlas allocation and disposal. |
src/vs/editor/browser/viewParts/viewLinesGpu/viewLinesGpu.ts |
Integrates blending and dynamic atlas storage. |
src/vs/editor/browser/gpu/renderStrategy/viewportRenderStrategy.ts |
Fixes drawing, scrolling, and buffer lifetime. |
src/vs/editor/browser/gpu/renderStrategy/fullFileRenderStrategy.wgsl.ts |
Makes glyph metadata storage dynamically sized. |
src/vs/editor/browser/gpu/renderStrategy/fullFileRenderStrategy.ts |
Repairs cache updates, scrolling, and draw counts. |
src/vs/editor/browser/gpu/renderStrategy/baseRenderStrategy.ts |
Unregisters disposed event handlers. |
src/vs/editor/browser/gpu/rectangleRenderer.ts |
Applies corrected alpha blending. |
src/vs/editor/browser/gpu/raster/glyphRasterizer.ts |
Preserves fractional device-pixel font sizes. |
src/vs/editor/browser/gpu/gpuUtils.ts |
Defines shared alpha blending state. |
src/vs/editor/browser/gpu/atlas/gpuAtlasStorage.ts |
Adds dynamically sized atlas resources. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Remove speculative ASCII, token-color and subpixel glyph prewarming. Keep the existing demand cache, page growth, theme invalidation and rasterization behavior. Add a regression test for idle allocation, cache reuse and clearing. The original prewarming path allocated 1693 glyphs where only the empty glyph and one requested glyph were expected. Validation on macOS: client build, targeted lint, and Chromium GPU suite (56 passing, 3 pending; headless GPU readback skipped without an adapter). Local Mac memory observations and minification experiments are separate from this source commit; cold-scroll timing and long-session growth remain unmeasured. AI-assisted investigation and implementation with OpenAI Codex under dalisoft direction.

TL;DR
Related reports: #249464, #277812. Detailed evidence is in the existing verification comment.
Enabling
editor.experimentalGpuAccelerationexposes several defects in the experimental renderer: washed-out glyph edges, excessive glyph instances, disappearing text at large scroll offsets, stale cache state, and unnecessary atlas storage. This fixes those paths and adds focused regression coverage.Related to the editor GPU tracking work in #221145, the large-file disappearance in #311373, stale-text reports #249464 / #237583, and fractional-scale report #277812. The linked reports include different platforms and remaining features; the verified scope is listed below.
AI disclosure and attribution: contributed by Davlatjon Sh (@dalisoft) with OpenAI Codex. The implementation, investigation, regression tests, automated builds, and validation were AI-generated under Davlatjon Sh (@dalisoft)'s direction. The evidence identifies each automated environment. The contributor reports glyphs and scrolling working on an M1 Max; broader visual checks and total-memory acceptance remain open. This PR is ready for maintainer review. Broader manual testing and total-memory acceptance remain open; the measurements and limitations below are retained.
Copilot review follow-up
Both Copilot findings are addressed by
3d8d4da0and228e79ff(current source228e79ffc4715b96a7475f63cd34d57939c07864). Both strategies record the pixel ratio of the last successful scroll-uniform upload. Unchangedupdate()frames do not upload; initialization, a changedbigNumbersDelta, or a changed display scale do. A scroll event uploads immediately and records the ratio so the next ordinary update does not duplicate it. Full-file origin changes still invalidate cached positions.VulkanFromANGLE; production startup is unchanged.This follow-up is AI-assisted under Davlatjon Sh (@dalisoft)'s direction as disclosed above. The published macOS archive and original hosted Mac measurements remain tied to
bdc89a4a. The later local Mac observations have their own build and workload scope below; no measured speedup is claimed for these review fixes.Root causes and changes
relativeVerticalOffsetsubtractsViewportData.bigNumbersDelta; the GPU scroll uniform did not. Both strategies now subtract the same delta. The full-file cache invalidates positions when the origin changes.2d-arrayview.Before / after
Line 50,000 in a 60,000-line editor
The before capture restores the three original strategy implementations in compiled output, retaining the corrected alpha and atlas storage to isolate strategy behavior. It renders the top correctly, then shows line numbers with zero content text pixels near line 50,000. The fixed capture contains 29,508 content text pixels in the same measured region. Both use the real editor view and GPU renderer; DOM text fallback is empty.
Packaged macOS workbench on an Apple adapter
The actual ad hoc signed Apple Silicon app renders the same large-file region without DOM text fallback. Its native adapter, enabled WebGPU, source revision and absence of captured GPU errors are recorded. The bounded content region excludes the gutter and bottom notification.
Alpha isolation
This independent WebGPU compositor illustrates the blend error with antialiased text, partial opacity and a translucent rectangle. It is a focused equation check. The production WGSL pixel test separately verifies the same alpha result through atlas growth and shrink.
Verification and durable evidence
The original validation table below covers source
bdc89a4a; the current follow-up results are listed above. Original captures, observations, control scripts, logs, source provenance and SHA-256 hashes live in an immutable evidence commit. The source PR contains 13 TypeScript files; fork build tooling and evidence are separate.[128,0,0,64]instead of[128,0,0,128]finallybdc89a4a)Linux controls and editor captures use the repository-pinned Chromium 149 / Playwright 1.61.1 with SwiftShader, and Xvfb for the headed editor captures. The integrated harness supplies the standalone theme instance's token palette from that same theme because its GPU accessor is empty; workbench themes provide the palette normally. Native Chromium scale factors were used so the canvas device-pixel dimensions match
ResizeObserver.devicePixelContentBox. Screenshot readback measures the presented pixels. The ink check confirms visibility; cache contents, draw arguments and uniforms have separate exact assertions.The complete fixed suite was rerun after both control experiments restored compiled output. Wrapping and the simple delete/undo unit sequence already pass on the original; they are retained as regression coverage, not claimed as original failures. The allocation interface is checked by unit tests and by real GPU readback across page counts 1 → 3 → 1.
Source
bdc89a4ais rebased onto upstream main04861ffb. Linux validation was generated at6b7eeb61; the entire editor, base and theme trees, Node version and dependency lockfiles were checked byte-identical across the rebase. Final macOS builds use the rebased source. The fork build workflow applies a documented packaging-only adjustment to retain the source-built Copilot SDK before SDK shim preparation; its original failure and exact patch are included in the evidence. Editor/client sources are unchanged by that adjustment.The evidence was checked for credentials, private keys, email addresses and private settings. Runner/checkout paths and long browser debug URLs were sanitized; assertions and results are retained. Generated fixtures contain no user project content. Automated CI checks establish behavior on those environments; broader testing on the contributor's Mac, the reported Windows configuration and RX 9070 XT remain separate manual targets.
Memory accounting and remaining scope
The capacity improvement is directly calculable from the RGBA8 texture descriptors:
Metadata storage starts at 120,000 bytes instead of 1,920,000 bytes. Old and new allocations can temporarily coexist during growth; populated pages are reuploaded, and usage can still require all 16 layers. These are allocated texture/buffer capacities, not total process/unified-memory measurements. The memory follow-up also removes speculative idle glyph prewarming, so the atlas caches glyphs requested by rendering rather than preallocating unused variants.
Latest controlled local Mac observation — October 10, 2026
M1 Max, 64 GB unified memory, 32-core GPU, macOS 27.0.1. The Code OSS 1.142.0 test package used a locally rebuilt minified workbench with the memory follow-up. Two fresh profiles opened the same local configuration folder with matching settings except editor GPU acceleration. The instances ran concurrently; the samples were taken approximately 55 seconds after launch. This is one paired observation, not repeated statistics or a before/after comparison against an unpatched build.
Values are the physical footprint reported by macOS
vmmap, retaining itsMunits and rounded precision. They replace the earlier Process Explorer screenshot estimates for the local comparison. The saved reports identify the process, launch time and sampling time.vmmapwarned that it could not examine Electron's PartitionAlloc malloc zone, so detailed allocation ownership is incomplete; these figures do not establish the root cause of every remaining allocation.Do not add these rows and label the result unique whole-app/unified memory. Other processes, shared mappings, peaks and longer workloads remain outside this comparison. The test package still advertises its original
bdc89a4apackaging commit; that metadata is not a provenance hash for the locally replaced bundles. The raw local reports have not been published in the immutable evidence archive. These measurements are also not an on/off comparison of the subsequently patched installed VS Code 1.141.0 app.The contributor reports enjoying the local build and that it may feel faster, while also reporting general OS sluggishness after the macOS upgrade. This is subjective feedback, not a benchmark or evidence that VS Code caused the OS slowdown. No measured speedup or whole-app memory acceptance is claimed. The historical observation and debugging guide remains available; the requested total-memory threshold remains unverified.
The feature tracker #221145 and missing-ligature work #301005 / #227120 remain broader tasks. Wrapped indentation #279526 / #238404 already works on this main revision and has coverage in both strategies. Terminal context loss #303488 is a separate renderer problem. This source branch contains the editor fix; terminal PR #340776 remains a separate contribution.
How to test
After installing dependencies with the repository's Node version:
The GPU pixel test explicitly skips when no adapter is available; inspect its result rather than inferring GPU coverage from the total.
For local macOS testing, download the Apple Silicon Code OSS build. The test guide and launcher create a dedicated test profile and a generated 60,000-line fixture. Compare GPU on/off after fully quitting between runs, check Quiet Light and a dark theme, large-file scrolling, delete/undo/redo, split panes, resize and fractional zoom. Record identical-workload memory and performance observations. The build is ad hoc signed and unnotarized; its checksum and source provenance are published with the download.