openframeworks / openframeworks/openFrameworks
macOS: problems around camera init / permissions
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
diagnosed within #7520: sometimes running OF apps from the command line (e.g. make RunRelease or other direct Unix execution vs opening a .app) creates tricky conditions with camera permissions (NB: when running from terminal, the "privacy identity" is the terminal and not the app binary per se).
from a pristine setup, the macOS dialog requesting the camera will popup and will grant the terminal the permissions but there are a couple problems around this:
-
the OF app is stuck in a limbo state (between the macOS dialog callback state, and somewhere within the control of the videoGrabber initialization). it needs to be quit and re-launched and then works. perhaps the videoGrabber could be smarter about that and have a state to reflect this limbo, and properly continue with init once the limbo is resolved. or at least quit OF cleanly with a console message saying why. this should only occur once in a given setup.
-
there are situations where the permissions become "conflicted" (there are probably more defined conditions but it's difficult to investigate): the dialog does not pop up, the interaction with the OS makes OF consider having access, but yet the OS does not provide a camera source. this causes a crash around
Can't add a nil AVCaptureInput. a way to recover from that is to reinitialize the camera permission (withtccutil). the conditions leading to that error could be detected in the Grabber code, and provide some information to the console about tccutil.
for reference this resolves things:
% cd $OF_ROOT/examples/3d/3DPrimitivesExample
% make clean
% make -j8
% rm ./bin/3DPrimitivesExample.app/Contents/Info.plist # optional, to be sure there is no interaction with the .plist
% make RunRelease
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureSession _addInputWithNoConnections:] *** Can't add a nil AVCaptureInput'
# WE ARE IN THE CONFLICTED PERMISSIONS STATE
% tccutil reset Camera
% make RunRelease
# ... CAMERA PERMISSION DIALOG
# ... <CLICK ALLOW> (dialog goes away)
# ... but APP IS STUCK IN LIMBO STATE ...
<Control-C>
% make RunRelease
# ... JOY
# ... and all subsequent terminal-based binaries will access the Camera without problems
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the macOS Grabber/videoGrabber initialization path and reproduce the terminal-based sequence using make RunRelease, tccutil reset Camera, and the 3DPrimitivesExample. Trace the permission callback and the AVCaptureInput failure; done should mean the limbo or conflicted-permission state is handled without a crash and provides useful console guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100