Skip to content

fix(recording): start the gated Instant screen track at the arm point - #2658

Merged
richiemcilroy merged 3 commits into
mainfrom
fix/instant-video-origin-at-gate
Oct 17, 2026
Merged

richiemcilroy merged 3 commits into
mainfrom
fix/instant-video-origin-at-gate

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Gated Instant recordings start their audio at the start gate's arm time (#2650), but the screen track started at its first admitted frame, 17 to 25 ms later. Instant merges its tracks by timestamp, so the screen played early by that delay.

Fix

The gated Instant video track now starts where its audio starts: the arm point, or the pipeline epoch if the gate armed before it (audio_epoch, the Linux composite-camera path can create its epoch late). The first admitted frame is shown from that origin, and every later frame is muxed at its capture time relative to it.

// crates/recording/src/output_pipeline/core.rs
fn shift_from_origin(duration: Duration, is_first_frame: bool, origin_lead: Option<(Instant, Duration)>) -> Duration {
    match origin_lead {
        Some((_, lead)) if !is_first_frame => duration + lead,
        _ => duration,
    }
}
  • RecordingStartGate::video_origin_lead (crates/recording/src/output_pipeline/start_gate.rs) gives the first frame's lead over that origin. primed_instant_video_armed_before_the_epoch_starts_at_the_epoch covers a gate armed before the epoch. Only the Instant pipeline turns it on (set_video_origin_at_arm in instant_recording.rs), behind a gate.
  • Capture times go through clock remapping and drift tracking unchanged; only the muxed timeline moves. The first version stamped the first frame with the arm instant instead, which the drift tracker read as 20 ms of hand-off lag, so it pulled the second frame back by the same amount (frames captured 20, 53 and 86 ms after the arm muxed at 0, 33 and 86 ms). primed_instant_video_starts_at_the_arm_point checks 0, 53 and 86 ms and fails with the shift disabled.
  • The recorded first timestamp, the encoder-pair start and the static tail use the arm point as the origin. The live path and the stop-time drain share the rule.
  • Studio aligns its tracks with each track's recorded start time and is unchanged.

Measured

recording/instant/gated (the app's start), real capture on a MacBook Pro, 5 recordings each:

main This PR
Screen vs microphone -4.4, -4.5, -3.8, -10.1, -20.1 ms +15.3, +15.1, +13.1, +15.7, +12.8 ms
Spread 16.3 ms 2.9 ms
Inside the -10 to +75 ms window 3 of 5 5 of 5
  • Blacksmith macOS 26: +18.6 ms, against -19.0, +8.8 and +14.1 ms on main's last run (one recording per run).
  • The flaky recording/instant/gated sync entry stays until more runner runs show it no longer fires.

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Gated Instant recordings now start video at the same origin as audio.

  • Gated Instant screen video starts where its audio starts.

No new actionable issues were found. The earlier test-coverage thread has an explanatory reply and regression coverage. Tests were inspected but not run.

Reviews (3) · Last reviewed commit: "fix(recording): start gated Instant vide..." · Reviewed by Greptile

Gated Instant audio starts at the gate's arm time, but the screen track
started at its first admitted frame, 17 to 25 ms later on a MacBook Pro,
so the screen played early by that delay. Instant merges its tracks by
timestamp, so its gate now stamps the first admitted frame at the arm
point; later frames keep their capture times. Studio, which aligns its
tracks with recorded start times, is unchanged.
@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 17, 2026 2:53am UTC

@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

View 1 other finding in Capy.

Open in Capy

Comment thread crates/recording/src/output_pipeline/core.rs Outdated
…s first capture time

Stamping the first admitted frame with the arm instant fed the video drift
tracker a capture time earlier than the frame's real one. The tracker read
the difference as hand-off lag, judged the next frame to be ahead of the
wall clock and pulled it back by the same amount: frames captured 20, 53
and 86 ms after the arm point were muxed at 0, 33 and 86 ms.

Capture times now pass through clock remapping and drift tracking
unchanged. The gate reports the first frame's lead over the arm point;
the first frame stays at the track start and every later frame is muxed
that much later, so the same frames land at 0, 53 and 86 ms. The recorded
first timestamp, the encoder-pair start and the static tail use the arm
point as the origin. Both the live and the stop-time drain paths share
the rule, and a pipeline test covers it.
@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 1 potential issue (1 medium).

Open in Capy

Comment thread crates/recording/src/output_pipeline/core.rs
@richiemcilroy

Copy link
Copy Markdown
Member Author

@greptileai review

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found no issues.

Open in Capy

@richiemcilroy
richiemcilroy merged commit 9ac5c9e into main Oct 17, 2026
51 checks passed

This branch was successfully deployed

2 active deployments
Preview – cap-web — 40be845a Deployed Oct 17, 2026 by vercel[bot]
Preview – cap-status — 40be845a Deployed Oct 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant