Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, isolated performance fix that replaces redundant PNG decoding with header-only dimension lookup while preserving the existing fallback path. Targeted tests cover both real PNG dimensions and invalid screenshots, with no product-default, schema, or deployment changes. You can add or adjust custom eligibility rules. Learn more. |
|
Note Written by Thanks for investigating snapshot overhead. Right now we are only taking focused bug fixes from outside contributors under our limited review capacity policy in Read this first. This PR removes a redundant PNG decode, but the supplied timings isolate dimension lookup and do not demonstrate a defect in the actual capture workflow. Please keep any reproducible capture delay in the linked issue, add measurements through that workflow, and agree on a focused fix with maintainers before requesting reconsideration. |
Problem
Snapshot accessibility decoded the entire captured PNG again just to read its dimensions. On Linux with Electron 44.4.5, that cost 3.77 ms for a 1440×900 PNG and 10.45 ms for a 2560×1600 PNG, synchronously on the desktop process.
Closes #19220
Change
Reuse the existing shared image-header reader. Capture backends already validate or encode the PNG; the logical-bounds fallback remains when dimensions are unavailable. Tests check persisted accessibility dimensions across GNOME, Niri, KDE, and Hyprland when captured pixels differ from logical window bounds, plus fallback behavior.
Scope and approval
This is a small, focused removal of proven redundant work under the obvious-bug exception in CONTRIBUTING.md. It changes no capture workflow, settings, contracts, or visual behavior. Searches found no matching issue or active PR; #16728 and #19193 concern different screenshot paths.
Verification
vp test run apps/desktop/src/snapShot/DesktopSnapShot.test.ts packages/shared/src/imageDimensions.test.ts: 123 passed, including an additional run using Electron's Node 24.21.0. The initial run used system Node 26.11.1.vp lint,vp fmt --check, desktoptsc-rs --noEmit, andgit diff --checkpassed. Typecheck emitted only two existing suggestions in unrelated tests.The timings isolate dimension lookup, not total capture latency or idle CPU. Live compositor captures and native macOS/Windows execution were not tested; their PNG producers and Electron's scale defaults were inspected. There is no UI change requiring before/after screenshots.
Implemented with GPT-6.1-Sol in the Codex harness. Reviewed by GPT-6-Astra at high reasoning effort.