Skip to content

perf(gpui): skip unused PCM preparation for GIF and cursor exports - #2569

Merged
richiemcilroy merged 6 commits into
CapSoftware:mainfrom
EfeDurmaz16:perf/gpui-video-only-export
Oct 20, 2026
Merged

richiemcilroy merged 6 commits into
CapSoftware:mainfrom
EfeDurmaz16:perf/gpui-video-only-export

Conversation

@EfeDurmaz16

@EfeDurmaz16 EfeDurmaz16 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

A short GIF or cursor-only MOV currently decodes every microphone and system audio source into retained PCM, even though these formats export no audio. GPUI now uses an explicit video-only builder backed by the existing segment loader without audio. Metadata probing still preserves recording duration; generic and MP4 preparation retain audio.

On Apple M5 Pro, a four-second export selected from a synthetic 30-minute recording with two 48 kHz stereo AAC sources measured:

Format Median complete export Median peak RSS
GIF 0.871 to 0.209 s 1458 to 123 MiB
Cursor MOV 1.120 to 0.479 s 1397 to 69 MiB

Three alternating pairs for each format and input length produced 24 complete exports. All 12 decoded-frame comparisons passed, including timestamps, durations and stream metadata. All six MOV comparisons additionally verify matching, visible moving alpha. The timer covers builder through encoder completion; configuration JSON loading and GPUI dialogs are excluded. Thirty-second controls show modest gains. These results are for the documented synthetic inputs, rather than a general export-speed claim.

Read order:

  1. crates/export/src/lib.rs: explicit video-only preparation, retaining the existing generic/MP4 branches.
  2. apps/desktop-gpui/src/editor_export.rs: use it only for GIF and cursor MOV.
  3. apps/desktop-gpui/examples/video-only-preparation.rs: same-binary baseline/candidate benchmark with no new dependencies.
  4. scripts/prepare-video-only-export-fixture.py, scripts/check-video-only-export-parity.py, and scripts/test-video-only-export-parity.py: disposable inputs, decoded frame/alpha comparison, and checker regression tests.
  5. apps/desktop-gpui/docs/video-only-export-performance.md: reproduction commands, controls and all 24 raw samples.

The handwritten production delta is 20 added and 3 removed lines. Reproduction scripts and a same-binary example include the raw measurements and parity checks. Alpha visibility validation reads fixed 64 KiB chunks and retains only extrema, avoiding full decoded-video buffering. No generated bindings change.

Validation already passed locally with the native dependencies configured:

python3 scripts/test-video-only-export-parity.py
cargo +stable test --locked -p cap-export --lib
cargo +stable check --manifest-path apps/desktop-gpui/Cargo.toml --locked --release -p cap-desktop-gpui --bin cap-gpui
cargo +stable build --manifest-path apps/desktop-gpui/Cargo.toml --locked --release --example video-only-preparation
cargo +stable clippy --manifest-path apps/desktop-gpui/Cargo.toml --locked --release --example video-only-preparation -- -D warnings
cargo +stable fmt --all -- --check
cargo +stable fmt --manifest-path apps/desktop-gpui/Cargo.toml --all -- --check

The 42 export unit tests pass. Four checker regression tests also pass, covering bounded reads/retention on a virtual 6.22 GB logical stream, alpha edge cases, FFmpeg failure propagation, and decoder cleanup on read failure. The virtual stream tests bounded consumption without allocating or decoding a real 6.22 GB payload. The checked-in fixture/example/checker were also exercised end to end. No-audio preparation succeeds in both modes; corrupt display video fails in both. Existing output and extension-normalized output protection are verified.

Reviewer note: corrupt unused audio can now succeed after a metadata warning instead of failing the complete PCM decode. This is an intentional behavior change for formats that export no audio. Metadata probing remains. Native UI timing and cancellation were not measured.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no actionable defects were found.

Summary

GIF and cursor MOV exports now skip full audio decoding through build_video_only. Generic and MP4 preparation keep their existing audio paths.

  • GIF and cursor-only MOV exports skip decoding audio tracks.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into perf/gpui-video..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@EfeDurmaz16 is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread scripts/check-video-only-export-parity.py Outdated
@richiemcilroy

Copy link
Copy Markdown
Member

@greptileai review

@richiemcilroy
richiemcilroy merged commit da9c8d9 into CapSoftware:main Oct 20, 2026
46 of 48 checks passed
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