Opt-in Permissions and Info.plist in macOS Catalina

Hi all.

I’m the developer of the NatDevice media device API which provides cross-platform media device control on iOS, Android, macOS, and Windows. On macOS Catalina, all permissions are now opt-in so there have been issues where the editor would crash if you tried to start the webcam or microphone. See [this post]( NatCorder - Video Recording API page-57#post-5669818) and this active bug report.

In NatDevice, I’ve implemented the native permissions request with AVFoundation. The problem is that even requesting permissions natively still crashes, and the culprit is in Unity’s Info.plist not defining a camera or microphone usage description (see attached).

And trying to add the NSCameraUsageDescription and NSMicrophoneUsageDescription keys to the Info.plist will prevent Unity from opening due to a code signing error:

Process:               Unity [88254]
Path:                  /Applications/Unity/Unity.app/Contents/MacOS/Unity
Identifier:            Unity
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        Unity Hub [37630]
Responsible:           Unity Hub [37630]
User ID:               501

Date/Time:             2020-04-24 08:28:48.941 -0400
OS Version:            Mac OS X 10.15.3 (19D76)
Report Version:        12
Anonymous UUID:        A6C8D7A4-775C-1082-038A-C099E3DB4614

Sleep/Wake UUID:       E11F3884-EBC5-46EE-88CF-F737323677AB

Time Awake Since Boot: 410000 seconds
Time Since Wake:       1200 seconds

System Integrity Protection: enabled

Crashed Thread:        Unknown

Exception Type:        EXC_CRASH (Code Signature Invalid)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x1

kernel messages:

Backtrace not available

Unknown thread crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x0000000000000000
  rdi: 0x0000000000000000  rsi: 0x0000000000000000  rbp: 0x0000000000000000  rsp: 0x00007ffeef914b18
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000000
  r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x0000000000000000  r15: 0x0000000000000000
  rip: 0x0000000111bc5000  rfl: 0x0000000000000200  cr2: 0x0000000000000000
 
Logical CPU:     0
Error Code:      0x00000000
Trap Number:     0


Binary images description not available


External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 5028242
    thread_create: 0
    thread_set_state: 0

Model: MacBookPro14,1, BootROM 204.0.0.0.0, 2 processors, Dual-Core Intel Core i5, 2.3 GHz, 8 GB, SMC 2.43f7
Graphics: kHW_IntelIrisGraphics640Item, Intel Iris Plus Graphics 640, spdisplays_builtin
Memory Module: BANK 0/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x80AD, 0x483943434E4E4E424A54414C41522D4E5644
Memory Module: BANK 1/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x80AD, 0x483943434E4E4E424A54414C41522D4E5644
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x170), Broadcom BCM43xx 1.0 (7.77.106.3 AirPortDriverBrcmNIC-1440.1)
Bluetooth: Version 7.0.3f5, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.0 Bus
Thunderbolt Bus: MacBook Pro, Apple Inc., 41.3

@ team, any thoughts on this? It’s a real blocker, and frustrated customers rate NatDevice poorly because of this issue even though it is through no fault of mine.

Here’s the permissions request code I’m P/Invoking into:

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
    handler(granted);
}];

And here’s the crash I get:

Thread 4 Crashed:: Dispatch queue: com.apple.root.default-qos
0   libsystem_kernel.dylib            0x00007fff662117fa __pthread_kill + 10
1   libsystem_pthread.dylib           0x00007fff662cebc1 pthread_kill + 432
2   libsystem_c.dylib                 0x00007fff66198a1c abort + 120
3   com.unity3d.UnityEditor5.x        0x0000000107cabd8e HandleSignal(int, __siginfo*, void*) + 62
4   libmonobdwgc-2.0.dylib            0x000000013864d5c1 mono_chain_signal + 79
5   libmonobdwgc-2.0.dylib            0x000000013864d904 sigabrt_signal_handler + 86
6   libsystem_platform.dylib          0x00007fff662c342d _sigtramp + 29
7   libsystem_c.dylib                 0x00007fff66181e1b __v2printf + 475
8   libsystem_kernel.dylib            0x00007fff6622c525 abort_with_payload + 9
9   com.apple.TCC                     0x00007fff5e37e5a7 __CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 163
10  com.apple.TCC                     0x00007fff5e37c545 __TCCAccessRequest_block_invoke.114 + 500
11  com.apple.TCC                     0x00007fff5e37ca6c __tccd_send_message_block_invoke + 231
12  libxpc.dylib                      0x00007fff66310a08 _xpc_connection_reply_callout + 36
13  libxpc.dylib                      0x00007fff66310990 _xpc_connection_call_reply_async + 69
14  libdispatch.dylib                 0x00007fff66071578 _dispatch_client_callout3 + 8
15  libdispatch.dylib                 0x00007fff66088080 _dispatch_mach_msg_async_reply_invoke + 369
16  libdispatch.dylib                 0x00007fff6608048c _dispatch_kevent_worker_thread + 1324
17  libsystem_pthread.dylib           0x00007fff662cb744 _pthread_wqthread + 362
18  libsystem_pthread.dylib           0x00007fff662ca827 start_wqthread + 15

Unity Team - any update on this?

Very serious issue - Unity incorrectly returns Permission.HasUserAuthorizedPermission(Permission.Microphone) as true on MacOS, even when the user has not granted permission.

This immediately causes a full game crash, as MacOS terminates apps using Microphone or Camera APIs when permission has not been granted.

Please fix as soon as possible - urgent issue for MacOS developers.

We’ve spent some time trying to get voice permissions as well while using Vivox. While it would attempt to join a channel, it would fail silently and not actually allow the microphone to transmit.

We discovered that in addition to ensuring NSMicrophoneUsageDescription
was in the plist in the mac app bundle package Contents when built, these entitlements also needed to be set:

com.apple.security.device.audio-input
com.apple.security.device.microphone
Then the signtool must be run (and a cert may be required)

Both the plist and entitlements must be done. Only modifying the plist may cause the app to crash or fail to open as described above
https://stackoverflow.com/questions/49595811/macos-entitlements-audio-input-vs-microphone

This should allow the app to popup a request for microphone permissions

1 Like

Could you show me how to set these entitlements?