New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add media access apis for mojave #15624
Conversation
ad39da6
to
e2477bf
Compare
2d73e0b
to
fbf4da5
Compare
We're 👍 on porting to 4.x post-merge if:
However, there is still outstanding debate on the actual API cc @nornagon @codebytere |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should return an enum, with all the 4 possible values as returned by the OS API. Being able to distinguish between denied and restricted is quite important to be able to show appropriate UI to the users of the apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think the API should just be a thin wrapper over the OS APIs. I would definitely not show any message boxes, let the app decide how to present that to the user.
Something like this:
getMediaAccessStatus(mediaType: 'audio' | 'video'): 'not-determined' | 'allowed' | 'denied' | 'restricted'
requestMediaAccess(mediaType: 'audio' | 'video'): Promise<boolean>
If you insist on providing a conveniece API, I would expose both the raw API, which provides all the states and just add an additional method to do that, which can be inplemented in JS using the low level APIs. This way the C++ code can stay much simpler and without any business logic |
+1 on @miniak's feedback - I think this API should do less to transform the data and be treated as more of a passthrough of Apple's data |
aac060f
to
f656488
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions are up there.
This should be ready for review again, i've addressed all the above comments and simplified the impl to remove opinionated behaviors 😀 |
@alexeykuzmin, @nornagon can you please check the refactored version? |
bdcedb3
to
5301b91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
2d5132e
to
2bc5505
Compare
Verified to work properly on macOS 10.13 |
@rspeyer can you sign-off as well? |
Release Notes Persisted
|
I have automatically backported this PR to "4-0-x", please check out #15948 |
I believe we still need to make default additions to the Electron.app/Contents/Info.plist file. Using this API in development is challenging given that NSMicrophoneUsageDescription and/or NSCameraUsageDescription are required by osx for the [AVCaptureDevice requestAccessForMediaType:type] call to succeed. Otherwise the app just crashes. I've temporarily solved this in my app by manually adding the keys to Electron.app/Contents/Info.plist in node_modules, then I call open ./node_modules/electron/dist/Electron.app -n -W --args $(pwd) to launch the app. This all still feels messy, and I doubt its what most uses are going to want to have to deal with. At least adding the default keys to Info.plist would help. Thoughts? |
Perhaps we can add some default generic strings to |
good plan, i'll look into doing that today! |
Description of Change
This PR adds new APIs to control new media privacy and consent rules introduced in MacOS Mojave. Namely:
Apple Docs:
Checklist
npm test
passesRelease Notes
Notes: Added media access APIs for macOS Mojave