Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Opt-in Permissions and Info.plist in macOS Catalina

Discussion in 'Editor & General Support' started by Lanre, Apr 24, 2020.

  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,575
    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 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).
    Screen Shot 2020-04-24 at 8.27.14 AM.png

    And trying to add the NSCameraUsageDescription and NSMicrophoneUsageDescription keys to the Info.plist will prevent Unity from opening due to a code signing error:
    Code (CSharp):
    1. Process:               Unity [88254]
    2. Path:                  /Applications/Unity/Unity.app/Contents/MacOS/Unity
    3. Identifier:            Unity
    4. Version:               ???
    5. Code Type:             X86-64 (Native)
    6. Parent Process:        Unity Hub [37630]
    7. Responsible:           Unity Hub [37630]
    8. User ID:               501
    9.  
    10. Date/Time:             2020-04-24 08:28:48.941 -0400
    11. OS Version:            Mac OS X 10.15.3 (19D76)
    12. Report Version:        12
    13. Anonymous UUID:        A6C8D7A4-775C-1082-038A-C099E3DB4614
    14.  
    15. Sleep/Wake UUID:       E11F3884-EBC5-46EE-88CF-F737323677AB
    16.  
    17. Time Awake Since Boot: 410000 seconds
    18. Time Since Wake:       1200 seconds
    19.  
    20. System Integrity Protection: enabled
    21.  
    22. Crashed Thread:        Unknown
    23.  
    24. Exception Type:        EXC_CRASH (Code Signature Invalid)
    25. Exception Codes:       0x0000000000000000, 0x0000000000000000
    26. Exception Note:        EXC_CORPSE_NOTIFY
    27.  
    28. Termination Reason:    Namespace CODESIGNING, Code 0x1
    29.  
    30. kernel messages:
    31.  
    32. Backtrace not available
    33.  
    34. Unknown thread crashed with X86 Thread State (64-bit):
    35.   rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x0000000000000000
    36.   rdi: 0x0000000000000000  rsi: 0x0000000000000000  rbp: 0x0000000000000000  rsp: 0x00007ffeef914b18
    37.    r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000000
    38.   r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x0000000000000000  r15: 0x0000000000000000
    39.   rip: 0x0000000111bc5000  rfl: 0x0000000000000200  cr2: 0x0000000000000000
    40.  
    41. Logical CPU:     0
    42. Error Code:      0x00000000
    43. Trap Number:     0
    44.  
    45.  
    46. Binary images description not available
    47.  
    48.  
    49. External Modification Summary:
    50.   Calls made by other processes targeting this process:
    51.     task_for_pid: 0
    52.     thread_create: 0
    53.     thread_set_state: 0
    54.   Calls made by this process:
    55.     task_for_pid: 0
    56.     thread_create: 0
    57.     thread_set_state: 0
    58.   Calls made by all processes on this machine:
    59.     task_for_pid: 5028242
    60.     thread_create: 0
    61.     thread_set_state: 0
    62.  
    63. Model: MacBookPro14,1, BootROM 204.0.0.0.0, 2 processors, Dual-Core Intel Core i5, 2.3 GHz, 8 GB, SMC 2.43f7
    64. Graphics: kHW_IntelIrisGraphics640Item, Intel Iris Plus Graphics 640, spdisplays_builtin
    65. Memory Module: BANK 0/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x80AD, 0x483943434E4E4E424A54414C41522D4E5644
    66. Memory Module: BANK 1/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x80AD, 0x483943434E4E4E424A54414C41522D4E5644
    67. AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x170), Broadcom BCM43xx 1.0 (7.77.106.3 AirPortDriverBrcmNIC-1440.1)
    68. Bluetooth: Version 7.0.3f5, 3 services, 27 devices, 1 incoming serial ports
    69. Network Service: Wi-Fi, AirPort, en0
    70. USB Device: USB 3.0 Bus
    71. Thunderbolt Bus: MacBook Pro, Apple Inc., 41.3
    @Unity 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.
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,575
    Here's the permissions request code I'm P/Invoking into:
    Code (CSharp):
    1. [AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
    2.     handler(granted);
    3. }];
    And here's the crash I get:
    Code (CSharp):
    1. Thread 4 Crashed:: Dispatch queue: com.apple.root.default-qos
    2. 0   libsystem_kernel.dylib            0x00007fff662117fa __pthread_kill + 10
    3. 1   libsystem_pthread.dylib           0x00007fff662cebc1 pthread_kill + 432
    4. 2   libsystem_c.dylib                 0x00007fff66198a1c abort + 120
    5. 3   com.unity3d.UnityEditor5.x        0x0000000107cabd8e HandleSignal(int, __siginfo*, void*) + 62
    6. 4   libmonobdwgc-2.0.dylib            0x000000013864d5c1 mono_chain_signal + 79
    7. 5   libmonobdwgc-2.0.dylib            0x000000013864d904 sigabrt_signal_handler + 86
    8. 6   libsystem_platform.dylib          0x00007fff662c342d _sigtramp + 29
    9. 7   libsystem_c.dylib                 0x00007fff66181e1b __v2printf + 475
    10. 8   libsystem_kernel.dylib            0x00007fff6622c525 abort_with_payload + 9
    11. 9   com.apple.TCC                     0x00007fff5e37e5a7 __CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 163
    12. 10  com.apple.TCC                     0x00007fff5e37c545 __TCCAccessRequest_block_invoke.114 + 500
    13. 11  com.apple.TCC                     0x00007fff5e37ca6c __tccd_send_message_block_invoke + 231
    14. 12  libxpc.dylib                      0x00007fff66310a08 _xpc_connection_reply_callout + 36
    15. 13  libxpc.dylib                      0x00007fff66310990 _xpc_connection_call_reply_async + 69
    16. 14  libdispatch.dylib                 0x00007fff66071578 _dispatch_client_callout3 + 8
    17. 15  libdispatch.dylib                 0x00007fff66088080 _dispatch_mach_msg_async_reply_invoke + 369
    18. 16  libdispatch.dylib                 0x00007fff6608048c _dispatch_kevent_worker_thread + 1324
    19. 17  libsystem_pthread.dylib           0x00007fff662cb744 _pthread_wqthread + 362
    20. 18  libsystem_pthread.dylib           0x00007fff662ca827 start_wqthread + 15
     
  3. musicdeveloper

    musicdeveloper

    Joined:
    Oct 16, 2019
    Posts:
    36
    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.
     
  4. VWAStudios

    VWAStudios

    Joined:
    May 22, 2020
    Posts:
    1
    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

    https://docs.unity3d.com/Manual/HOWTO-PortToAppleMacStore.html

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