Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(verify): Windows timer resolution for real-time fixtures; Instant audio xfail off Linux

Richie McIlroyfc11008f9b40
diff --git a/.github/workflows/verify-platforms-tmp.yml b/.github/workflows/verify-platforms-tmp.yml
index 054f0fd38..a6c9a16fd 100644
--- a/.github/workflows/verify-platforms-tmp.yml
+++ b/.github/workflows/verify-platforms-tmp.yml
@@ -133,6 +133,7 @@ jobs:
for run in $(seq 1 "$REPEATS"); do
for test in codec export playback seek; do
export CAP_VERIFY_REPORT_DIR="$OUT/run$run/$test"
+ export CAP_VERIFY_FIXTURE_DIR="$GITHUB_WORKSPACE/verify-fixtures-run$run"
mkdir -p "$CAP_VERIFY_REPORT_DIR"
start=$(date +%s)
cargo test --locked -p cap-verify --test "$test" -- --nocapture > "$OUT/run$run/$test.log" 2>&1
diff --git a/crates/verify/expectations.toml b/crates/verify/expectations.toml
index cf503a589..1dd424897 100644
--- a/crates/verify/expectations.toml
+++ b/crates/verify/expectations.toml
@@ -144,7 +144,8 @@ link = ""
[[xfail]]
case = "export/instant/output/mp4/native"
class = "audio"
-reason = "NEW: mic plus loopback system audio mixed into the Instant audio track behind the start gate: every system-audio marker is missing from output.mp4 (11 of 11, 3 of 3 recordings)"
+platforms = ["macos", "windows"]
+reason = "NEW: mic plus loopback system audio mixed into the Instant audio track behind the start gate: every system-audio marker is missing from output.mp4 (11 of 11, 3 of 3 recordings; same on windows-2022). Linux, whose Instant audio pipeline anchors at the recording epoch (AudioAnchor::PipelineEpoch), keeps all 11 system markers (3 of 3 CI runs), which points at the FirstFrame anchor path"
link = ""
[[xfail]]
diff --git a/crates/verify/src/pipeline.rs b/crates/verify/src/pipeline.rs
index 456fbb899..aef09b782 100644
--- a/crates/verify/src/pipeline.rs
+++ b/crates/verify/src/pipeline.rs
@@ -407,7 +407,26 @@ async fn record_segment(
/// Records a Studio project (one recording segment per spec segment, like
/// pause/resume) into `dir`.
+/// The emitters sleep until each frame's time. Windows wakes timers on its
+/// default 15.6 ms tick, which by itself makes frames up to a tick late
+/// (more under load); the product raises the timer resolution the same way
+/// for playback and export.
+fn high_resolution_timer() {
+ #[cfg(windows)]
+ {
+ #[link(name = "winmm")]
+ unsafe extern "system" {
+ fn timeBeginPeriod(period: u32) -> u32;
+ }
+ static ONCE: std::sync::Once = std::sync::Once::new();
+ ONCE.call_once(|| unsafe {
+ timeBeginPeriod(1);
+ });
+ }
+}
+
pub async fn record_studio(spec: &RecordedSpec, dir: &Path) -> anyhow::Result<()> {
+ high_resolution_timer();
crate::media::init();
if dir.exists() {
std::fs::remove_dir_all(dir)?;
@@ -458,6 +477,7 @@ pub struct Emitted {
}
pub async fn record_instant(spec: &InstantSpec, dir: &Path) -> anyhow::Result<()> {
+ high_resolution_timer();
use cap_recording::{DashSegmentedAudioMuxer, DashSegmentedAudioMuxerConfig};
crate::media::init();
if dir.exists() {