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
systemPreferences.askForMediaAccess(mediaType) causes app to crash in macOS Mojave #19307
Comments
|
@fgladisch I see you didn't note a last working version: can you please check and add that? |
|
We have the same issue in version 4.0.0, which introduced |
|
|
|
We are also suspecting that it is related to code signing. We don't seem to be having this issue when the app is started in development mode. Also pretty weird: The app (signed version) does not crash when started from Terminal. The prompt is coming from the Terminal in this case. |
|
Update: The TCC log revealed what the problem is: We created an entitlements file with this content: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.device.audio-input</key>
<true/>
</dict>
</plist>Unfortunately this also leads to an immediate crash (this time before asking for microphone access): The signed app seems to be valid. Code Signature: Certificate Check: |
|
Update 2: Disabling "Hardened Runtime" through {
"mac": {
"hardenedRuntime": false
}
}Everything seems to work now, including the microphone access prompt with the string set in |
|
@fgladisch Please check the Hardened Runtime documentation for entitlements --> https://developer.apple.com/documentation/bundleresources/entitlements?language=objc If you want the ability to access the microphone you need to add the |
|
As I've said above: we already did that. This leads to the process immediately crashing with this crash report: https://gist.github.com/fgladisch/534fd60c37b5308a51c14966985f0ffd The TCC log indicates that the entitlement is correctly set. The app crashes regardless. This seems to be a bug affecting Electron under MacOS 10.14.5 or higher. |
|
That crash appears to indicate that you did not codesign the binary correctly.
You can verify your code signature using
Just as a general rule, if the thing is only crashing when certain code signing entitlements are applied, 99.99% of the time it isn't an electron issue, it's either invalid signing or an incorrect choice of entitlements |
After adding the following entitlement my app stopped crashing just after start: <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>It seems that some part of Electron application (the framework itself or some part of the bundled Chromium) generates runtime code and puts it in the writeable memory area, that's why application immediately crashes with @MarshallOfSound @codebytere I believe it should be noted somewhere in the documentation, that any Electron application to be built with The whole working <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
</dict>
</plist>Also to be able to use camera and microphone in your application {
"build": {
"mac": {
"entitlements": "build/entitlements.mac.plist",
"extendInfo": {
"NSCameraUsageDescription": "This app requires camera access to record video.",
"NSMicrophoneUsageDescription": "This app requires microphone access to record audio."
}
}
}
}Without this information your application will be killed by OS after call |
|
It works for the I would appreciate any help as I already spent whole day with this, thanks in advance |
|
steps to reproduce what i'm talking about in previous comment:
code fragment 1 question on stackoverflow: |
@fgladisch thanks !!! it works now !! this is what i looking for. once again, thanks man. |
|
How can you notarize without hardened runtime? |
you can't. this is the whole point of notarization: imposing e predictable hardened runtime. |
@Nodarii were you able to figure this out? |
Preflight Checklist
Issue Details
askForMediaAccess())Expected Behavior
User should be prompted to grant microphone access.
Actual Behavior
App crashes with the following error report: https://gist.github.com/fgladisch/04f1c62b46dae37d55f05d001af7d7ee
To Reproduce
The app crashes as soon as this line is called:
We have included a
NSMicrophoneUsageDescriptionin ourInfo.plistas described here.Here is the full function we use to request media access. It is called when the Permission Request Handler is invoked with the
mediapermission. The app does not reach thecatchBlock, so the error is not logged. We tested this behaviour on 3 different machines.The text was updated successfully, but these errors were encountered: