Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(verify): merge the real-capture recording oracle

Richie McIlroy7a07c56fb55a
diff --cc .github/workflows/verify-recording.yml
index 000000000,995b6217d..af63b47a4
mode 000000,100644..100644
--- a/.github/workflows/verify-recording.yml
+++ b/.github/workflows/verify-recording.yml
@@@ -1,0 -1,131 +1,156 @@@
+ name: Verify recording (real capture)
+
+ # Records a marker stimulus through Cap's real Studio and Instant pipelines
+ # (ScreenCaptureKit + VideoToolbox) on hosted macOS runners and checks every
+ # frame and audio marker against the host-clock truth. See
+ # crates/verify/tests/recording.rs.
+
++# Pull requests (and pushes to the suite branches) that touch the capture,
++# encode, timestamp or verify code run the FAST tier once on macos-15; the
++# FULL tier runs on macos-15 and macos-26 nightly and on dispatch.
+ on:
+ workflow_dispatch:
+ inputs:
+ repeat:
+ description: "Runs of each case"
+ default: "1"
+ tier:
+ description: "fast or full"
- default: "fast"
++ default: "full"
+ case_filter:
+ description: "Case globs, comma-separated (empty runs all)"
+ default: ""
+ keep_artifacts:
+ description: "Preserve recordings and raw crash snapshots for passing cases"
+ type: boolean
+ default: false
++ schedule:
++ - cron: "41 3 * * *"
++ pull_request:
++ paths:
++ - "crates/recording/**"
++ - "crates/scap-*/**"
++ - "crates/enc-avfoundation/**"
++ - "crates/timestamp/**"
++ - "crates/camera*/**"
++ - "crates/media-info/**"
++ - "crates/verify/**"
++ - "crates/project/**"
++ - "Cargo.lock"
++ - ".github/workflows/verify-recording.yml"
+ push:
+ branches:
++ - ci/verify-ci
+ - ci/verify-recording
+ paths:
- - "crates/verify/**"
+ - "crates/recording/**"
++ - "crates/scap-*/**"
++ - "crates/enc-avfoundation/**"
++ - "crates/timestamp/**"
++ - "crates/camera*/**"
++ - "crates/media-info/**"
++ - "crates/verify/**"
++ - "crates/project/**"
++ - "Cargo.lock"
+ - ".github/workflows/verify-recording.yml"
+
+ concurrency:
- group: verify-recording-${{ github.ref_name }}
- cancel-in-progress: true
++ group: verify-recording-${{ github.event.pull_request.number || github.ref_name }}-${{ github.event_name }}
++ cancel-in-progress: ${{ github.event_name != 'schedule' }}
+
+ permissions:
+ contents: read
+
+ jobs:
+ real-capture:
+ strategy:
+ fail-fast: false
+ matrix:
- runner: [macos-15, macos-26]
++ runner: ${{ fromJSON((github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && '["macos-15", "macos-26"]' || '["macos-15"]') }}
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 45
+ env:
+ CAP_VERIFY_CAPTURE: display
+ CAP_VERIFY_REQUIRE_CAPTURE: "1"
- CAP_VERIFY_TIER: ${{ inputs.tier || 'fast' }}
- CAP_VERIFY_REPEAT: ${{ inputs.repeat || '5' }}
++ CAP_VERIFY_TIER: ${{ inputs.tier || (github.event_name == 'schedule' && 'full') || 'fast' }}
++ CAP_VERIFY_REPEAT: ${{ inputs.repeat || (github.event_name == 'schedule' && '3') || '1' }}
+ CAP_VERIFY_CASE: ${{ inputs.case_filter || '' }}
+ CAP_VERIFY_KEEP: ${{ inputs.keep_artifacts && '1' || '' }}
+ CAP_VERIFY_SCRATCH: ${{ github.workspace }}/verify-scratch
+ CAP_VERIFY_REPORT_DIR: ${{ github.workspace }}/verify-report
+ CAP_VERIFY_DUMP: ${{ github.workspace }}/verify-dump
+ CAP_VERIFY_AUDIO_OUTPUT: ${{ matrix.runner == 'macos-26' && 'Null Audio Device' || '' }}
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: dtolnay/[email protected]
+
+ - uses: ./.github/actions/setup-rust-cache
+ with:
+ target: aarch64-apple-darwin
+ prefix-key: v1-rust-verify-recording-${{ matrix.runner }}
+ save-cache: "true"
+
+ - uses: ./.github/actions/install-desktop-deps
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 24
+
+ - name: Native dependencies
+ env:
+ RUST_TARGET_TRIPLE: aarch64-apple-darwin
+ run: node scripts/setup.js
+
+ - name: Runner devices
+ run: |
+ sw_vers
+ system_profiler SPDisplaysDataType SPAudioDataType 2>/dev/null | sed -n 1,80p
+ sysctl hw.memsize hw.ncpu
+
+ # Spotlight indexes the build and every recording the suite writes:
+ # mds (priority 50) plus a dozen mdworkers averaged 1 to 1.8 of the 3
+ # cores during the tests (ps samples, run 38736744971).
+ - name: Disable Spotlight indexing
+ run: |
+ sudo mdutil -a -i off || true
+ sudo mdutil -as || true
+
+ - name: Build
+ run: |
+ start=$(date +%s)
+ cargo test --locked -p cap-verify --test recording --no-run
+ echo "build seconds: $(( $(date +%s) - start ))"
+
+ - name: Real-capture recording oracle
+ run: |
+ mkdir -p "$CAP_VERIFY_DUMP"
+ # One-second process samples (CPU, scheduler priority) so an
+ # environment failure can be attributed.
+ (while sleep 1; do
+ date -u +%H:%M:%S
+ ps -A -o pid,pri,%cpu,comm -r | head -14
+ for p in $(pgrep -f cap-verify-stimulus | head -1) $(pgrep -f 'deps/recording-' | head -1); do
+ ps -M -p "$p" | awk 'NR == 1 || $4 > 0.5 || NR < 4' | cut -c1-90
+ done
+ done) > "$CAP_VERIFY_DUMP/ps.log" 2>&1 &
+ top_pid=$!
+ start=$(date +%s)
+ set +e
+ cargo test --locked -p cap-verify --test recording -- --nocapture
+ status=$?
+ set -e
+ kill "$top_pid" || true
+ echo "test seconds: $(( $(date +%s) - start ))"
+ exit "$status"
+
+ - name: Upload artifacts
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
+ with:
+ name: verify-recording-${{ matrix.runner }}
+ path: |
+ ${{ github.workspace }}/verify-report
+ ${{ github.workspace }}/verify-dump
+ ${{ github.workspace }}/verify-scratch
+ if-no-files-found: ignore
diff --cc Cargo.lock
index 6c5bfd6bb,904a958c1..1fade8024
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -2165,18 -2163,23 +2165,23 @@@ dependencies =
"cap-recording",
"cap-rendering",
"cap-timestamp",
+ "cap-verify-expect",
"cidre",
+ "cpal 0.15.3 (git+https://github.com/CapSoftware/cpal?rev=6013cb5f8bd3)",
"ffmpeg-next",
"flume",
"futures",
+ "objc2-foundation 0.3.1",
"relative-path",
"rustfft",
+ "scap-targets",
"serde",
"serde_json",
+ "softbuffer",
"tempfile",
"tokio",
- "toml 0.8.2",
"tracing-subscriber",
+ "winit",
"workspace-hack",
]
diff --cc crates/verify/Cargo.toml
index 2678ea749,288608098..4f16eeb83
--- a/crates/verify/Cargo.toml
+++ b/crates/verify/Cargo.toml
@@@ -28,11 -28,23 +28,24 @@@ workspace-hack = { version = "0.1", pat
[target.'cfg(target_os = "macos")'.dependencies]
cap-enc-avfoundation = { path = "../enc-avfoundation" }
cidre = { workspace = true }
+ cpal = { workspace = true }
+ objc2-foundation = "0.3.1"
+ softbuffer = "0.4"
+ winit = "0.30"
[dev-dependencies]
+ cap-recording = { path = "../recording", features = ["test-utils"] }
-cap-editor = { path = "../editor" }
+cap-editor = { path = "../editor", features = ["test-hooks"] }
+cap-audio = { path = "../audio" }
cap-export = { path = "../export" }
cap-rendering = { path = "../rendering" }
tempfile = "3"
-tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
+tracing-subscriber = { version = "0.3", features = ["env-filter"] }
+
+ [target.'cfg(target_os = "macos")'.dev-dependencies]
+ scap-targets = { path = "../scap-targets" }
+
+ [[bin]]
+ name = "cap-verify-stimulus"
+ path = "src/bin/stimulus.rs"
+ test = false
diff --cc crates/verify/expectations.toml
index 79ff0f638,2c91bfbf8..697c8b6e0
--- a/crates/verify/expectations.toml
+++ b/crates/verify/expectations.toml
@@@ -221,88 -169,91 +221,165 @@@ reason = "On the macos-15 runner (parav
link = "https://github.com/CapSoftware/Cap/pull/2603"
[[xfail]]
-case = "seek/seek-*/keyframes60/ffmpeg"
+case = "seek/seek-native/keyframes60/ffmpeg"
class = "stale"
platforms = ["linux", "windows"]
-reason = "NEW: FFmpeg decoder seeks near the start show frame 0 (frame 124 at 60 fps shows source 0 instead of 61) and one keyframe seek answers one frame stale (linux runner; the x264 fallback fixture)"
-# Real-capture recording oracle (tests/recording.rs): ScreenCaptureKit +
-# VideoToolbox through the real Studio and Instant pipelines. Measured on the
-# hosted macos-15 and macos-26 runners (display capture, 5 runs each) and on a
-# developer Mac (window capture, 5 runs). Root cause for every Instant entry
-# below: each Instant track takes its own first admitted frame as zero
-# (screen: first encoded frame; audio: AudioAnchor::FirstFrame, the mixer's
-# first output) and finalize_instant_output muxes both at pts 0, so any
-# difference in first-frame times becomes a permanent A/V offset. Confirms the
-# CORE track's fixture findings with real capture.
+reason = "NEW: FFmpeg decoder. Off macOS this fixture is libx264 (the AVFoundation encoder is unavailable), so its keyframe set and shuffled request order differ from macOS. Requests 366 (6.1 s), 1, 124 (all 60 fps seeks): 124 shows source frame 0 for 61, the first-frame shortcut bug of seek/seek-gop/home-then-play30/ffmpeg. Request 490 shows 243 for 244: the 2-frame backward lookback tolerance. seek-gop/keyframes60/ffmpeg passes on both. Identical on Linux and Windows, 3 of 3 runs each"
+link = ""
+
+[[xfail]]
+case = "editing/mapping/duration-covered"
+class = "coverage"
+reason = "NEW: a fullscreen text segment (a hold) left past the end of the clips (place a text card near the end, then trim or delete clips; clip edits do not ripple text segments) still adds its length to TimelineConfiguration::duration(), but get_frame_mapping returns None from the content end on, so the hold and the time before it have no source frame. Minimal repro: Hold at 0.92 of a 7 s clip, then trim the clip end"
+link = ""
+
+[[xfail]]
+case = "editing/export/hold-past-end"
+class = "frame-count"
+reason = "NEW: same as editing/mapping/duration-covered, end to end: a 1 s fullscreen text at 5.4 s and the clip trimmed to 3.2 s give a 4.2 s timeline, but the export stops at the first unmapped frame: 96 frames instead of 126, and the text card is never rendered"
+link = ""
+
+[[xfail]]
+case = "captions/app/segmentation/unicode"
+class = "caption-segments"
+reason = "NEW (minor): caption chunking decides that a boundary word is a weak one-letter word with String::len() (bytes), so a one-letter word outside ASCII such as the French preposition 'à' is not weak and a caption can end on it (apps/desktop-gpui/src/transcription.rs caption_boundary_word_is_weak). Repro: cargo test --manifest-path apps/desktop-gpui/Cargo.toml --bin cap-gpui segmentation_matches_reference_unicode -- --nocapture"
+link = ""
+
+[[xfail]]
+case = "captions/legacy-migration/ends-at-timeline-end"
+class = "caption-migration"
+reason = "NEW (minor): loading a legacy (output-timed) project drops a caption that ends exactly at the timeline end: synchronize_captions maps each end through source_start + (end - start) / timescale, which rounds just below the timeline end after a clip transition (clips 41/15 s and 82/15 s, 0.2 s transition: 7.9999999 < 8.0), so the end does not map and the whole caption is discarded"
+link = ""
+
+[[xfail]]
+case = "editing/export/multi-segment/seed-7"
+class = "stale"
+reason = "FFmpeg decoder (full tier): after the timeline played clip 0 from 1.68 s to its end and then transitions back into clip 0 at 0 s, the 10 frames after the transition show source frame 0 instead of 20-29 (deterministic). Same mechanism as the seek/*/storm*/ffmpeg xfail: backward seeks near the start answer frame 0"
+link = ""
+
+[[xfail]]
+case = "editing/export/same-clip-transition/forward/ffmpeg"
+class = "stale"
+reason = "NEW: FFmpeg decoder, cross-fade between two parts of the same recording clip (0-2 s, then 3-5.5 s, 0.8 s transition): the export reads one decoder at two positions interleaved and every third blend frame takes the far side from the near position (frame 37: incoming should be source 90, shows 35; up to 55 source frames stale). Deterministic; AVAssetReader passes this case (its 60 fps variant is the */basic/transition/*60*/avf xfail)"
+link = ""
+
+[[xfail]]
+case = "editing/export/basic/seed-5"
+class = "stale"
+reason = "FFmpeg decoder, same-clip cross-fade (see editing/export/same-clip-transition/forward/ffmpeg): blend frame 53 one source frame stale"
+link = ""
+
+[[xfail]]
+case = "editing/export/basic/seed-23"
+class = "stale"
+reason = "FFmpeg decoder (full tier), same-clip cross-fade (see editing/export/same-clip-transition/forward/ffmpeg): blend frames up to 70 source frames stale"
+link = ""
+
+[[xfail]]
+case = "editing/export/multi-segment/seed-7"
+class = "unreadable"
+reason = "FFmpeg decoder (full tier): one blend frame of the transition back into clip 0 mixes two stale frames and its marker is unreadable (same bug as the stale entry above)"
+link = ""
+
+[[xfail]]
+case = "seek/seek-gop/home-then-play30/ffmpeg"
+class = "stale"
+reason = "NEW: FFmpeg decoder freezes on the first frame after a jump to the start. Seek 6.1 s, seek 0, seek 2.0 s and play: 31 of 122 frames show source frame 0 (up to 89 frames stale, about 1 s frozen). A request at grid 0..2 is answered by the first-frame shortcut (ffmpeg.rs, requested_frame <= MAX_FRAME_LOOKBACK_TOLERANCE) without resetting the reader, which stays near 6 s, and last_sent_frame becomes frame 0; the next request is then not 'far forward' of frame 0 (< FRAME_CACHE_SIZE), so no reset happens, the reader vends frames past the request and the answer falls back to last_sent_frame (frame 0) until playback outruns FRAME_CACHE_SIZE. Main decoder on Linux and on Windows without a D3D11 video device; macOS AVAssetReader passes. Minimal: CAP_VERIFY_SEEK_SCRIPT='seek-gop@60:6.1,0.0167,2.0667' (third request shows frame 0 for 61)"
+link = ""
+
+[[xfail]]
+case = "export/basic/colour-red/mp430/*"
+class = "colour-level"
+reason = "NEW: export converts rendered RGBA to NV12 with BT.601 coefficients (GPU: crates/rendering/src/shaders/rgba_to_nv12.wgsl; software adapters: convert_rgba_to_nv12 in crates/rendering/src/lib.rs) but the encoder tags the stream BT.709 (crates/enc-ffmpeg/src/video/h264.rs), so players decode renderer-generated colour (backgrounds, captions, cursor, text) shifted: background (220,40,40) decodes about 13 luma code values too bright. Screen video whose decode matrix matches passes through unchanged"
+link = ""
+
+[[xfail]]
+case = "export/basic/colour-red/mp430/*"
+class = "colour-matrix"
+reason = "NEW: same root cause as colour-level (BT.601 coefficients in an export tagged BT.709): background (220,40,40) decodes Cb about 9 code values low"
+link = ""
+
+[[xfail]]
+case = "playback/basic/cuts-speeds-reorder/realtime30-from25/avf"
+class = "stale"
+platforms = ["macos"]
+flaky = true
+reason = "NEW: the real-time playback loop (cap_editor::Playback prefetch, AVAssetReader) shows source frame 58 instead of 59 for the last two output frames of the 0.5x segment that follows the 2x segment (4.200 s and 4.233 s, screen and camera); offline frame stepping and export of the same timeline show 59. 3 of 3 runs on Apple silicon; passed on the macos-15 runner in run 38743345280, where the loop presents fewer frames, so it is timing dependent there"
+link = ""
++
++# Real capture (crates/verify/tests/recording.rs, verify-recording workflow).
+
+ [[xfail]]
+ case = "recording/instant/screen-mic-system"
+ class = "sync"
+ platforms = ["macos"]
+ reason = "NEW: the Instant screen track starts at its first encoded frame (the VideoToolbox encoder starts after the audio pipeline), so the screen plays early against mic and system audio: runners 34 to 92 ms (10 of 10 runs), developer Mac 340 to 570 ms (8 of 8)"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/long-holds"
+ class = "sync"
+ platforms = ["macos"]
+ reason = "NEW: same as recording/instant/screen-mic-system on a 30 s recording with screen holds (developer Mac: screen 375 ms early)"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/late-mic"
+ class = "sync"
+ platforms = ["macos"]
+ reason = "NEW: a microphone whose first sample arrives 1.0 s after the recording starts becomes audio zero, so all audio plays early by its start-up delay minus the screen's: runners 974 to 1040 ms (10 of 10), developer Mac 677 to 728 ms (5 of 5)"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/system-only"
+ class = "sync"
+ platforms = ["macos"]
+ reason = "NEW: Instant with system audio and no microphone: the first ScreenCaptureKit audio buffer becomes audio zero, so system audio plays 140 to 184 ms early (developer Mac, 8 of 8). Skipped on hosted runners, whose output devices give ScreenCaptureKit only silence"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/system-only"
+ class = "unreadable"
+ platforms = ["macos"]
+ flaky = true
+ reason = "NEW: Instant system-only: one system-audio marker inside the track does not decode (a discontinuity inside the marker) in 4 of 5 developer-Mac runs"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/gated"
+ class = "sync"
+ platforms = ["macos"]
+ flaky = true
+ reason = "NEW: the app's Instant start (start gate armed by the start cue): the screen-to-audio offset varies run to run: runners -22 to +16 ms (6 of 20 runs below the -10 ms floor), developer Mac +2 to +385 ms (3 of 13 above +75 ms); logs show 'Start gate admitted first audio frame at the arm point' followed by overlap trims of up to 124 ms"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/gated"
+ class = "missing"
+ platforms = ["macos"]
+ flaky = true
+ reason = "NEW: gated Instant with microphone and system audio loses an audio marker near the start in 2 of 5 developer-Mac runs (and 3 of 3 in an earlier batch); not seen on runners, where system audio is silent"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/gated"
+ class = "unreadable"
+ platforms = ["macos"]
+ flaky = true
+ reason = "NEW: see the gated Instant missing-marker entry: the damaged marker straddles the admission point"
+ link = ""
+
+ [[xfail]]
+ case = "recording/instant/gated"
+ class = "timestamps"
+ platforms = ["macos"]
+ flaky = true
+ reason = "NEW: gated Instant microphone timeline not continuous after the gate opens: marker offsets vary by 5 to 852 ms within one recording (4 of 8 developer-Mac runs)"
+ link = ""
+
+ [[xfail]]
+ case = "recording/studio-recovery/*"
+ class = "sync"
+ platforms = ["macos"]
+ reason = "NEW: crash recovery rebuilds recording-meta.json without any track start_time (the in-progress meta has no segments), so the editor aligns screen, mic and system audio at 0 and the screen plays early by its start-up delay: runners 59 to 104 ms (all runs), developer Mac 317 to 555 ms (all runs)"
+ link = ""