Skip to content

Add stable Retina 4K 60 fps capture - #160

Merged
swellweb merged 1 commit into
swellweb:dev-3.4.0from
Betafer:codex/retina-4k60
Aug 9, 2026
Merged

swellweb merged 1 commit into
swellweb:dev-3.4.0from
Betafer:codex/retina-4k60

Conversation

@Betafer

@Betafer Betafer commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

A short story

First of all, thank you for TargetBridge — I genuinely enjoyed the project and its approach.

I had a 21.5-inch 2017 Retina 4K iMac next to a Mac mini M4 and wanted to reuse the iMac's excellent panel instead of buying another display. TargetBridge was the first solution I tried that felt close to turning that machine into a real monitor. While testing it daily over direct links, I experimented with a few additions. I am splitting them by purpose so each idea can be reviewed, accepted or declined independently.

This PR is only the display-quality part. The complete prototype and proposed split are described in #157; measured USB4/network path selection is separate in #159.

What this PR adds

  • a dedicated retina4k60 preset matching the 21.5-inch iMac panel: 4096 × 2304 at 60 fps, HEVC, 120 Mbps;
  • explicit retina4k, 4096x2304 and imac4k automation aliases while preserving the existing 4k alias for 3840 × 2160;
  • capture headroom plus a zero-buffer frame pacer, so scheduler tolerance does not reduce a nominal 60 fps stream to roughly 53–55 fps;
  • five ScreenCaptureKit surfaces for high-rate profiles and three for the standard profile;
  • direct frame handling on the pipeline queue, avoiding an extra dispatch and returning IOSurfaces to WindowServer sooner;
  • capture of the receiver-native mirrored virtual display when available, avoiding unnecessary scaling from the sender's physical display;
  • audio capture setup only when audio streaming is enabled;
  • counters for captured, paced and backpressure-dropped frames in verbose diagnostics;
  • localized preset naming, CLI/docs updates and focused regression tests.

Why the pacer requests more than 60 callbacks

SCStreamConfiguration.minimumFrameInterval behaves as a minimum interval, not a guaranteed cadence. Requesting exactly 1/60 left measurable refreshes unused on the Mac mini M4. The capture request therefore has scheduling headroom, while TBFrameRatePacer applies the actual 60 fps ceiling before encoding. It does not buffer frames and resets after idle gaps, so it cannot build up a burst.

Validation

  • Xcode test suite: 90 passed, 0 failed, 0 skipped on macOS;
  • JSON localization files and CLI shell syntax validated;
  • git diff --check clean.

The integrated prototype using this same 4K pipeline was also exercised on the actual Mac mini M4 → 2017 21.5-inch Retina 4K iMac setup for about three minutes of high-entropy full-screen motion: sender remained at 60 fps, receiver varied around 59–61 fps, with no observed pipeline backlog or dropped-frame counters. That hardware run predates this intentionally smaller branch, so the automated results above are the reproducible validation for this PR.

Deliberately out of scope

  • USB4/Thunderbolt/Ethernet/Wi-Fi path discovery and benchmarking (Add measured USB4 and network path selection #159);
  • headless startup, reconnect ownership and receiver-side Start/Stop;
  • keyboard, mouse and clipboard relay;
  • display/audio controls and notification shielding;
  • installer or packaging changes.

Those are kept separate so this PR can be judged strictly as a capture-quality improvement.

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