Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test: require the first picture after each hold, xfail the ScreenCaptureKit idle-resume loss

Richie McIlroy7b2de9bab0ee
diff --git a/crates/verify/expectations.toml b/crates/verify/expectations.toml
index 697c8b6e0..b1f4d18bb 100644
--- a/crates/verify/expectations.toml
+++ b/crates/verify/expectations.toml
@@ -383,3 +383,38 @@ 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 = ""
+
+# First picture after a static screen. During a scripted hold ScreenCaptureKit
+# delivers only Idle status buffers; its first Complete frame after the hold
+# arrives 70 to 82 ms after the new picture was presented (steady state 23 to
+# 31 ms after each present), and it already shows the next picture. Frame-level
+# logs (run 38745219281, macos-15: every SCK screen buffer with its
+# SCStreamFrameInfoStatus, every Cap send, every mux call) show 0 Complete
+# frames between the post-hold picture and the next one, and 1797 Complete
+# frames = 1797 Cap sends = 1797 mux calls: the picture never reaches Cap's
+# capture callback and Cap drops nothing. The stimulus presents through the
+# standard Core Animation path, so a user's first change after a static screen
+# is affected the same way: it is recorded ~50 to 80 ms late and anything
+# shown for less than that is lost.
+
+[[xfail]]
+case = "recording/studio-screen/mp4-holds"
+class = "missing-after-hold"
+platforms = ["macos"]
+reason = "NEW (ScreenCaptureKit idle resume, see above): the first 20 fps picture after each of the 3 holds is never delivered by ScreenCaptureKit (first Complete frame 80 to 82 ms after it was presented); runners 18 of 18 holds in 6 runs"
+link = "https://github.com/CapSoftware/Cap/actions/runs/38745219281"
+
+[[xfail]]
+case = "recording/instant/long-holds"
+class = "missing-after-hold"
+platforms = ["macos"]
+reason = "NEW (ScreenCaptureKit idle resume, see above): the first 15 fps picture after a hold is never delivered when the resume takes longer than its 67 ms (first Complete frame 70 to 74 ms after it was presented); runners: hold at 6 s 6 of 6 runs, hold at 18 s 4 of 6, at least one per run 6 of 6"
+link = "https://github.com/CapSoftware/Cap/actions/runs/38745219281"
+
+[[xfail]]
+case = "recording/studio-camera/long"
+class = "missing-after-hold"
+platforms = ["macos"]
+flaky = true
+reason = "NEW (ScreenCaptureKit idle resume, see above): the first 15 fps picture after the 3 s hold is missing when the resume takes longer than its 67 ms; runners 5 of 6 runs (flaky because the 70 to 82 ms resume straddles the 67 ms picture)"
+link = "https://github.com/CapSoftware/Cap/actions/runs/38745219281"
diff --git a/crates/verify/tests/recording.rs b/crates/verify/tests/recording.rs
index 7fd0454dd..f07e1e291 100644
--- a/crates/verify/tests/recording.rs
+++ b/crates/verify/tests/recording.rs
@@ -734,6 +734,10 @@ struct Recorded {
camera: Option<(Truth, Vec<u32>)>,
max_fps: u32,
mic_delay: f64,
+ /// The stimulus's scripted holds and rate, to locate the first picture
+ /// after each hold.
+ holds: Vec<(f64, f64)>,
+ stimulus_fps: f64,
/// Recovery after a crash may lose at most this many seconds before the
/// crash (the in-flight fragment).
loss_budget: Option<f64>,
@@ -1118,6 +1122,8 @@ async fn record(
camera: camera_truth,
max_fps,
mic_delay: spec.mic_delay,
+ holds: spec.holds.clone(),
+ stimulus_fps: spec.stimulus_fps,
loss_budget,
})
}
@@ -1559,6 +1565,10 @@ struct VideoCheck<'a> {
/// guarantee a sample (screen only).
may_skip: Box<dyn Fn(u32) -> bool + 'a>,
allow_duplicates: bool,
+ /// Pictures that must each be in the recording, outside any loss budget:
+ /// the first picture after each scripted hold (a change after a static
+ /// screen, the moment a viewer is waiting for).
+ required: Vec<(u32, String)>,
}
fn check_video(case: &mut Case, track: &Track, check: VideoCheck) -> anyhow::Result<Offsets> {
@@ -1716,6 +1726,18 @@ fn check_video(case: &mut Case, track: &Track, check: VideoCheck) -> anyhow::Res
(best.max(run), run, Some(i))
})
.0;
+ for (index, what) in &check.required {
+ if check.truth.contains_key(index)
+ && *index > lo
+ && *index < hi
+ && !first_seen.contains_key(index)
+ {
+ case.problem(
+ "missing-after-hold",
+ format!("{name}: {what} (index {index}) is missing from the recording"),
+ );
+ }
+ }
if skipped.len() > budget || longest_run >= 3 {
case.problem(
"missing",
@@ -1950,6 +1972,22 @@ fn check_audio(
offsets
}
+/// The first presented picture after each scripted hold.
+fn after_holds(rec: &Recorded, truth: &Truth) -> Vec<(u32, String)> {
+ rec.holds
+ .iter()
+ .filter_map(|&(start, length)| {
+ let first = ((start + length) * rec.stimulus_fps).ceil() as u32 + 1;
+ truth.range(first..).next().map(|(&index, _)| {
+ (
+ index,
+ format!("first picture after the {length} s hold at {start} s"),
+ )
+ })
+ })
+ .collect()
+}
+
fn analyze(rec: &Recorded, reference: u64, case: &mut Case) -> anyhow::Result<()> {
let layout = layout(&rec.project, case)?;
let screen_truth = first_presented(&rec.stimulus, reference);
@@ -1977,6 +2015,7 @@ fn analyze(rec: &Recorded, reference: u64, case: &mut Case) -> anyhow::Result<()
.is_some_and(|d| *d < capture_interval + refresh)
}),
allow_duplicates: true,
+ required: after_holds(rec, &screen_truth),
},
)?;
let camera = match (&layout.camera, &rec.camera) {
@@ -1992,6 +2031,7 @@ fn analyze(rec: &Recorded, reference: u64, case: &mut Case) -> anyhow::Result<()
not_sent: dropped,
may_skip: Box::new(|_| false),
allow_duplicates: false,
+ required: Vec::new(),
},
)?)
}