Skip to content

fix(macos): allow camera open retry after failure - #58

Open
wysaid wants to merge 3 commits into
mainfrom
codex/camera-permission-review-20261119
Open

wysaid wants to merge 3 commits into
mainfrom
codex/camera-permission-review-20261119

Conversation

@wysaid

@wysaid wysaid commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

A failed macOS camera open leaves the provider holding its internal camera object, so a subsequent open on the same provider fails as if a camera were already open. Clean up that object on failure so the caller can retry.

Add a macOS regression test exercising the real provider with mocked authorization. It checks that an off-main-thread request completes without servicing the main queue and that a denied request does not prevent a subsequent attempt.

Validation

  • macOS Debug conversion suite: 901 passed, 2 skipped (AVX2 unavailable); camera-dependent grab timeout tests excluded.
  • The regression test fails when either the old main-queue dispatch or the old failed-open cleanup behavior is restored.
  • Authorization callbacks are simulated; the real OS permission prompt and Windows were not tested.

Follow-up to #56.

Summary by CodeRabbit

  • Bug Fixes
    • Apple camera startup now handles failed opens cleanly and reports the failure, helping ensure that later open attempts can proceed correctly.
    • Camera access requests from background threads behave more reliably, including when authorization is denied.
    • Rust device discovery now processes the available device names more reliably.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0461419f-dbd4-4814-b776-f674b03f360c
Commits

Reviewing files that changed from the base of the PR and between a5799c4 and 685363c.

Files selected for processing: 2

  • src/ccap_imp_apple.mm
  • tests/test_apple_permission.mm

No actionable comments were generated in the recent review.

Walkthrough

The Apple camera provider now clears its capture object when opening fails. A macOS regression test checks repeated authorization denial from a worker thread. Rust device enumeration and ARM64 QEMU installation are also updated.

Changes

Apple camera open and authorization test

Layer / File(s) Summary
Handle camera-open failure
src/ccap_imp_apple.mm
When [m_imp open] fails, the provider destroys the capture object, clears m_imp, and returns false.
Test repeated authorization denial
tests/test_apple_permission.mm, tests/CMakeLists.txt
The macOS test target includes a test that opens the provider twice from a worker thread. Mocked authorization methods deny access, and the test checks that both opens fail and two access requests occur.

Rust device iteration

Layer / File(s) Summary
Iterate over device names
bindings/rust/src/provider.rs
get_devices iterates over deviceNames entries up to deviceCount, instead of indexing the array.

ARM64 test emulation setup

Layer / File(s) Summary
Install QEMU for emulation
.github/workflows/linux-build.yml
The ARM64 Release emulation step directly installs qemu-user. Its existing workflow condition remains unchanged, and the step no longer requests qemu-user-static.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: leegodamn

Merge Risk: Minimal · previous review a5799

This change lets a macOS camera open be retried after a failure, and it also makes small CI and Rust binding adjustments. No merge-blocking risk was identified; the real OS permission prompt and Windows were not tested.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(macos): allow camera open retry after failure" matches the main change. The objectives say a failed macOS camera open left the internal camera object held, so a second open on the same …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(macos): allow camera open retry after failure" matches the main change. The objectives say a failed macOS camera open left the internal camera object held, so a second open on the same provider failed. The ccap_imp_apple.mm change destroys that partial object, clears m_imp, and returns false on failure, which enables the retry. The title is specific and concise and does not cover the supporting CI and test edits, which is acceptable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the camera light,
Then hops where worker threads take flight.
Two denials counted, neat and clear,
Device names march without a fear.
QEMU joins the build-time cheer.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bb1140ef-d4eb-4a26-b350-c2c22daecbe7
Commits

Reviewing files that changed from the base of the PR and between 982251b and a5799c4.

Files selected for processing: 2

  • .github/workflows/linux-build.yml
  • bindings/rust/src/provider.rs

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

This branch has not been deployed

No deployments
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.

1 participant