Bug 562179 - Java apps run from Eclipse on macOS 10.15.4 (Catalina) cannot access Mic, Camera, etc.
Summary: Java apps run from Eclipse on macOS 10.15.4 (Catalina) cannot access Mic, Cam...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.16   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Releng-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-15 13:54 EDT by J Nader CLA
Modified: 2020-12-16 03:33 EST (History)
5 users (show)

See Also:


Attachments
Sound recording and playback demo application (11.87 KB, application/octet-stream)
2020-04-15 13:54 EDT, J Nader CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description J Nader CLA 2020-04-15 13:54:06 EDT
Created attachment 282454 [details]
Sound recording and playback demo application

After a recent macOS upgrade to 10.15.4 (Catalina) java programs launched from within Eclipse can no longer capture data from the local audio and video devices.  This occurs for a clean install of Eclipse for Java 2020-03 (eclipse-java-2020-03-R-macosx-cocoa-x86_64.dmg) running with AdoptOpenJDK 13.0.2 or OpenJDK 14.0.1.

The symptoms do not include error messages.  When launching from within Eclipse the received device data is all zero's, which is silence for audio and black for video. The same program runs correctly from an iTerm bash shell using the command line generated from the Eclipse run configuration.  One work-around to the problem is to launch the Eclipse application from an iTerm bash shell command line.  When using this work-arounds, the audio and video data are captured correctly.

macOS Catalina changes in permissions is the likely culprit.  With Catalina, there are additional requirements for applications to explicitly request permissions for mic and camera usage.  This is accomplished by adding entries the Info.plist file of any installed application.  The two related entries that are required are:

<key>NSMicrophoneUsageDescription</key>
<string>Need microphone access for uploading videos</string>
<key>NSCameraUsageDescription</key>
<string>Need camera access for uploading Images</string>

The same java app launched from within Intellij works correctly.  Intellij does include these Info.plist entries, which may explain why.  See the following for more details on this new Apple requirement: 
https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos.

Locally I am not able to confirm these Info.plist entires will fix the issue because I cannot modify the entires prior to installing the application.  When I attempt to do so the install fails digital signature verification.  Modifying Info.plist after installation seems to have no effect.

An open source demo application with which I was able recreate this problem is attached to this report.  Launched from within Eclipse, recording with this demo only plays silence.  Running the same demo from the command line records from the system mic and plays it back.
Comment 1 Ed Merks CLA 2020-04-16 02:14:16 EDT
The signing with entitlements is something that's part of the releng process.
Comment 2 Sravan Kumar Lakkimsetti CLA 2020-04-21 01:04:37 EDT
@Lakshmi, Do you have an idea about these entries in Info.plist? can you please check this requirement?

Thanks
Comment 3 Sravan Kumar Lakkimsetti CLA 2020-04-21 06:11:31 EDT
Can you create a gerrit patch with changes? 

Here is the link for infoe.plist. https://git.eclipse.org/c/equinox/rt.equinox.framework.git/tree/features/org.eclipse.equinox.executable.feature/bin/cocoa/macosx/x86_64/Eclipse.app/Contents/Info.plist

Thanks
Comment 4 Lakshmi P Shanmugam CLA 2020-04-21 09:42:46 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #2)
> @Lakshmi, Do you have an idea about these entries in Info.plist? can you
> please check this requirement?
> 

From the documentation this is requirement since 10.14. I tried to add the entries to Info.plist and run the example but as mentioned in description, it didn't seem to have an effect. I'm not sure, but may be the Info.plist gets cached and so the changes don't have any effect. 
We can try the changes in a build and see if it fixes the problem.
Comment 5 Sravan Kumar Lakkimsetti CLA 2020-04-21 23:55:32 EDT
(In reply to Lakshmi Shanmugam from comment #4)
> (In reply to Sravan Kumar Lakkimsetti from comment #2)
> > @Lakshmi, Do you have an idea about these entries in Info.plist? can you
> > please check this requirement?
> > 
> 
> From the documentation this is requirement since 10.14. I tried to add the
> entries to Info.plist and run the example but as mentioned in description,
> it didn't seem to have an effect. I'm not sure, but may be the Info.plist
> gets cached and so the changes don't have any effect. 
> We can try the changes in a build and see if it fixes the problem.

That would be a good idea. Lets try that
Comment 6 J Nader CLA 2020-05-01 10:23:45 EDT
I found additional important information.  

In addition to the Info.plist of the bundled app, the Entitlements must be set when the app bundle is signed.  If a process has the Info.plist entries, but does not have the associated entitlements, it will be terminated by macos when it requests access.

Here are the relevant entitlements missing from Eclipse 2020-03 for audio and camera resources:

  <key>com.apple.security.device.audio-input</key>
  <true/>
  <key>com.apple.security.device.camera</key>
  <true/>

The Apple developer website shows a list of other useful resource request entitlements here, under 'See Also - Resource Access': https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_device_audio-input


I check the entitlements for my local Eclipse 2020-03 install:

run 'codesign -d --entitlements :- /Applications/Eclipse-2020-03.app/'

Executable=/Applications/Eclipse-2020-03b.app/Contents/MacOS/eclipse
<?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.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.debugger</key>
    <true/>
</dict>
Comment 7 Olaf Brandt CLA 2020-12-16 03:33:07 EST
It is working for microphone access with the following Info.plist entry:

<key>NSMicrophoneUsageDescription</key>
<string>To enable audio input for recording in Eclipse, click OK (recommended). 
You can also enable audio input later in System Preferences &gt; Security &amp; Privacy &gt; Privacy &gt; Microphone.</string>

The app needs to be codesigned after changing the Info.plist.

I verified this with macos 11.1 and Eclipse

Version: 2020-09 (4.17.0)
Build id: 20200910-1200

The keys needed for camera access, etc. may be found in this document:

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW25