Skip to content

fix(video): support iOS device recording on macOS 26 Tahoe - #938

Open
truebit wants to merge 2 commits into
facebook:mainfrom
truebit:main
Open

fix(video): support iOS device recording on macOS 26 Tahoe#938
truebit wants to merge 2 commits into
facebook:mainfrom
truebit:main

Conversation

@truebit

@truebit truebit commented Jul 14, 2026

Copy link
Copy Markdown

Motivation

Fixes #894.

Physical-device video recording can fail on macOS 26 Tahoe for two independent reasons:

  1. idb_companion did not embed its processed Info.plist in the command-line Mach-O. As a result, TCC could not reliably read NSCameraUsageDescription, and camera authorization was neither explicitly requested nor clearly diagnosed.
  2. Tahoe may expose the muxed iOS screen source with an AVCaptureDevice.uniqueID that differs from the device's hardware UDID. The previous AVCaptureDevice(uniqueID: device.udid) lookup therefore returned nil until the existing 10-second timeout expired.

These failures could surface as a missing camera permission prompt or an MJPEG/H264/etc first-frame timeout because no video reached the client.

Changes

Camera privacy and authorization

  • Embed the companion's processed Info.plist into the command-line Mach-O with CREATE_INFOPLIST_SECTION_IN_BINARY=YES.
  • Explicitly inspect and log the .video authorization state.
  • Call AVCaptureDevice.requestAccess(for: .video) when authorization is notDetermined.
  • Return actionable errors for denied, restricted, and unknown states.
  • Verify that every produced Mach-O slice contains the expected camera privacy metadata.

Tahoe capture-device discovery

  • Declare NSCameraUseContinuityCameraDeviceType in the companion Info.plist.
  • Keep direct UDID lookup as the fast path.
  • Fall back to an availability-aware AVCaptureDevice.DiscoverySession:
    • macOS 14 and later: external and Continuity Camera devices
    • Earlier supported versions: external unknown devices
  • Select only muxed devices whose model is iOS Device.
  • Resolve transformed identifiers using the following ambiguity-safe order:
    1. Unique normalized UDID match
    2. Unique exact device-name match
    3. Single screen source when only one iOS device is connected
  • Reject ambiguous matches instead of selecting an arbitrary source.
  • Log capture-device inventory changes and successful matches.
  • Preserve the existing 10-second discovery timeout.

Test Plan

  • bash -n build.sh
  • Build FBDeviceControl successfully.
  • Compile the Swift video test bundle.
  • Run 7 camera-authorization tests and 6 capture-device resolution tests: 13 passed, 0 failed.
  • Build idb_companion.
  • Verify that the arm64 and x86_64 binaries contain:
    • NSCameraUsageDescription
    • NSCameraUseContinuityCameraDeviceType = true

The complete FBDeviceControlTests target remains blocked by a pre-existing issue on main: FBAMDeviceTests.swift cannot find FBCreateZeroedAMDCalls.

Embed idb_companion's processed Info.plist into every command-line Mach-O slice so NSCameraUsageDescription is available to TCC. Add a build and packaging verifier that rejects missing or mismatched privacy metadata.

Check Camera authorization before CMIO device discovery, log the initial and post-request states, request access when notDetermined, and fail with actionable errors for denied, restricted, or unknown states. This makes permission failures distinguishable from Tahoe capture-device discovery failures.

Add unit coverage for authorized, denied, restricted, unknown, and notDetermined transitions, including the guarantee that denied authorization stops before CMIO setup and device discovery.

Port the implementation to main's Swift FBDeviceVideo and relocated Companion project introduced by 61c982f and b75d8f5. Keep main's arm64 build and distribution flow while verifying every Mach-O slice present in the resulting CLI.

Verification: bash syntax validation passes; the generated Companion Xcode project contains CREATE_INFOPLIST_SECTION_IN_BINARY; FBDeviceControl and the new Swift test bundle compile with Xcode 26.3; all 7 focused authorization tests pass. The full companion build reaches the idb_companion Swift target but remains blocked by main's pre-existing missing ReplProtocol module configuration from acba50b.
@meta-cla

meta-cla Bot commented Jul 14, 2026

Copy link
Copy Markdown

Hi @truebit!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jul 14, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Jul 14, 2026
Keep the direct AVCaptureDevice UDID lookup as the fast path, then reuse an availability-aware discovery session to enumerate external and Continuity devices when Tahoe exposes the iOS screen source under a transformed identifier.

Match only muxed devices whose model is iOS Device. Prefer a unique normalized-UDID match, fall back to a unique exact device-name match, and use the sole candidate only when the requested UDID is the only connected device. Log inventory changes and reject ambiguous matches while retaining the existing 10-second fast timeout.

Declare NSCameraUseContinuityCameraDeviceType in the companion Info.plist and extend the build verifier to require both camera privacy keys in every Mach-O architecture. Add Swift unit coverage for transformed identifiers, name and singleton fallbacks, filtering, and ambiguity handling.
@truebit truebit changed the title fix(video): request macOS camera authorization explicitly fix(video): support iOS device recording on macOS 26 Tahoe Jul 14, 2026
@meta-codesync

meta-codesync Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@xgerrit has imported this pull request. If you are a Meta employee, you can view this in D111925521.

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.

video-stream not working on macOS 26 Tahoe

1 participant