Flutter web app is crashing DUE_TO_PRIVACY_VIOLATION in debug (camera permissions)

801

Solution 1

This seems similar to the problem here: https://github.com/microsoft/vscode/issues/95062. The Flutter application needs permission through whatever IDE you're using for debugging.

  • Run VSCode from the terminal using the command 'sudo /Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron'
  • Start you Flutter application that asks for camera/microphone.
  • You'll be asked for permissions and the application shouldn't crash.
  • Terminal will be in the list of applications with camera/mic permissions and the Flutter application should work when run like this from now on.

See Mac OS Mojave microphone permission for Visual Studio Code for more information.

Solution 2

I was able by allowing vscode permissions for camera and microphone, but I had to create these entitled permissions in first place.

Have a look at this, this is where I found it: https://github.com/microsoft/vscode/issues/95062#issuecomment-751241372

Share:
801
groznny
Author by

groznny

Updated on December 23, 2022

Comments

  • groznny
    groznny over 1 year

    I'm working on some Flutter web app that uses the camera and mic input. For development, I'm using VS Code on macOS (Catalina). When I start the app, the Chrome instance is started. This instance is some sort of 'development' Chrome window (I'm completely new to the Web and Flutter development, so I'm not sure about the terminology) and it is completely separated from the (let's say) 'production' Chrome window.

    Here is the problem:

    • When the camera input is requested, this 'development' Chrome prompts the user to allow access to the camera and mic. After allowing access, the application crashes immediately, with the reason __CRASHING_DUE_TO_PRIVACY_VIOLATION__.
    • On the other hand, if I run the web-server (on a local machine) with the same code and access that port from the 'production' Chrome, everything is working fine. After allowing access to the camera and mic (in Chrome), OS prompts its request for allowing access to the camera and mic (on Chrome behalf), and after allowing that one, I get camera input.

    Using this approach (web-server + 'production' Chrome) doesn't seem a good way to do the development, since I don't know how to debug my code this way. I understand that every application on Mac has to have entitlements and usage descriptions defined to access the camera and mic, and this would be the easy fix if it was the native app. But in this case, I'm not sure how to make 'development' Chrome to act like 'production' Chrome. It just acts like it is missing entitlements for the camera and mic usage and crashes.

    Does anybody have an idea how to overcome this obstacle? Am I missing something in setting up Flutter environment?

    P.S. Posting some Flutter/Dart code here will not make any difference. flutter-webrtc-demo will crash in the same way. Any web app that uses a camera, when opened in this 'development' Chrome instance, will crash in the same way (I've tried only with Teams, but I'm pretty sure that all others will do the same).

    Crash log:

    Identifier:            com.google.Chrome
    Version:               85.0.4183.83 (4183.83)
    Code Type:             X86-64 (Native)
    Parent Process:        dart [11176]
    Responsible:           Electron [5097]
    User ID:               515352633
    
    Date/Time:             2020-09-02 12:55:10.488 +0200
    OS Version:            Mac OS X 10.15.5 (19F101)
    Report Version:        12
    Bridge OS Version:     4.5 (17P5300)
    Anonymous UUID:        9159D7A7-AA5D-B3F0-C032-A79F092DC4C1
    
    
    Time Awake Since Boot: 9100 seconds
    
    System Integrity Protection: enabled
    
    Crashed Thread:        31  Dispatch queue: com.apple.root.default-qos
    
    Exception Type:        EXC_CRASH (SIGABRT)
    Exception Codes:       0x0000000000000000, 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY
    
    Termination Reason:    Namespace TCC, Code 0x0
    
    Application Specific Information:
    Calling encodeRestorableStateWithCoder: on window of class 'NSKVONotifying_BrowserNativeWidgetWindow' with title 'localhost:54518/#/' (delegate is 0x7fca60ec9ac0)
    
    ...............
    
    Thread 31 Crashed:: Dispatch queue: com.apple.root.default-qos
    0   libsystem_kernel.dylib          0x00007fff6bdb3ad6 __abort_with_payload + 10
    1   libsystem_kernel.dylib          0x00007fff6bdb53df abort_with_payload_wrapper_internal + 80
    2   libsystem_kernel.dylib          0x00007fff6bdb5411 abort_with_payload + 9
    3   com.apple.TCC                   0x00007fff6249759f __CRASHING_DUE_TO_PRIVACY_VIOLATION__ + 163
    4   com.apple.TCC                   0x00007fff62495531 __TCCAccessRequest_block_invoke.114 + 500
    5   com.apple.TCC                   0x00007fff62495a58 __tccd_send_message_block_invoke + 231
    6   libxpc.dylib                    0x00007fff6be9828f _xpc_connection_reply_callout + 36
    7   libxpc.dylib                    0x00007fff6be98217 _xpc_connection_call_reply_async + 69
    8   libdispatch.dylib               0x00007fff6bbf96c2 _dispatch_client_callout3 + 8
    9   libdispatch.dylib               0x00007fff6bc1015d _dispatch_mach_msg_async_reply_invoke + 369
    10  libdispatch.dylib               0x00007fff6bc085f9 _dispatch_kevent_worker_thread + 1316
    11  libsystem_pthread.dylib         0x00007fff6be53a85 _pthread_wqthread + 362
    12  libsystem_pthread.dylib         0x00007fff6be52b77 start_wqthread + 15
    
  • groznny
    groznny over 3 years
    I have tried to run VS Code from Terminal with sudo "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" - and it works ... Was asked for permission and the Terminal is in the list of allowed apps for the camera. Each time I run VS Code from the Terminal (even without sudo) I have all permissions I need. Thanks a lot man :)