Vscode-js-debug: Instant crash when accessing navigator.getUserMedia

Created on 18 Mar 2020  路  31Comments  路  Source: microsoft/vscode-js-debug

Attempting to access the camera or microphone either through code or the console will result in the chrome instance crashing

  • VS Code Version: 1.43.0
  • Chrome Version 80
  • Log file (set "trace": true in launch config):

Steps to reproduce:

  1. Start a Chrome instance using VS Code Chrome Debug
  2. Open console and paste in this line: navigator.getUserMedia({video:true},devices=>{console.log('hello')},err=>{console.log(err)})
  3. Allow access to the camera
  4. Chrome will crash without a trace
bug verified

Most helpful comment

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:
https://github.com/microsoft/vscode/issues/95062#issuecomment-751241372

Now all works for me when started directly from vscode!

MacOS Catalina (10.15.7)

All 31 comments

  • old debug adapter: crash
  • chrome devtools: works
  • js-debug: I don't get the prompt from Chrome for camera access

This works for me in js-debug. Did you previously deny camera access on localhost:N? That would prevent it from prompting again.

Maybe, I changed the url to google.com and then I get the crash with js-debug too.

hm, still works for me there. Can you or loadpixels get a trace log?

The log shows a normal launch then disconnection, I don't think there's anything interesting. I tried with "userDataDir": false, setting a port to use that instead of the debug pipe, and commenting out all the flags we set when we spawn Chrome.

One thing I noticed, if I start Chrome from the terminal and do this, then after I click Allow, I get a macOS prompt to allow iTerm access to the camera. So maybe vscode/Electron doesn't want to allow access to the camera.

@loadpixels what OS are you on?

@roblourens MacOS

echoing @connor4312 there's no tracelog to speak of, it just crashes

it happens as soon as I click the Allow button on the permissions dialog

I experience the same problem. MacOS. I accept camera, and chrome immediately exits. Under VS Code debug only, works well in browser.

You can use an "attach" type config to work around this. I don't have anything better, sorry.

Doesn't seem to happen on Windows. Tracking upstream with: https://bugs.chromium.org/p/chromium/issues/detail?id=1066155

After discussion in the Chromium issue, we have opened a feature request here: https://bugs.chromium.org/p/chromium/issues/detail?id=1070364

Once that is ready we will need to do a small amount of work to support it.

Hi, any updates on this? browser crashes for me too when trying to allow microphone permissions.

We're still waiting on work from the Chromium team for this

Hi, still no updates on this? My browser crashes for me too when trying to allow microphone permissions.

What's the workaround here?

Work around:

Start Chrome with debug enabled

OSX:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

use attach in launch.json

"name": "Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}/src",

Perhaps helpful:

Starting chrome with debug enabled still crashes on MacOS once navigator.mediaDevices.getUserMedia is invoked.

Google Chrome 86.0.4240.80聽(Official Build)聽(x86_64)
OS macOS Version 10.15.7
Command Line /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --remote-debugging-port=9222 --flag-switches-begin --flag-switches-end
Debug Extension v4.12.11

Has anyone found any reasonable workaround? It's difficult to debug applications that use MediaDevices.

@robclouth, use the suggestion from @murray-minito above. Not ideal, but works for now.

Chrome: Version 87.0.4280.67 (Official Build) (x86_64)
OS: macOS Catalina 10.15.7
the problem is still here((

@amnporter it doesn't work. Still crashes when getUserMedia is called as @Odame has said, even when not debugging.

It's been working for me since trying it

On chrome 87.0.4280.67 if I start with --remote-debugging-port=9222 and run navigator.getUserMedia({video:true},devices=>{console.log('hello')},err=>{console.log(err)}) from the console it crashes, even without connecting vscode.

I think this is chrome issue, not vscode

[1121/143318.062403:WARNING:process_memory_mac.cc(93)] mach_vm_read(0x7ffee480b000, 0x2000): (os/kern) invalid address (1)
[1121/143318.177972:WARNING:crash_report_exception_handler.cc(240)] UniversalExceptionRaise: (os/kern) failure (5)

This happens with the firefox VSCode debugger as well. It looks like running the debugging server on either FF or Chrome doesn't have the correct 'entitlements' on Mac OS, due to notarization changes with 10.14+. Any user media permissions will instantly crash the application.

The only way out seems to be a separately notarized app dedicated to running as a debug server, with all these entitlements enabled.

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:
https://github.com/microsoft/vscode/issues/95062#issuecomment-751241372

Now all works for me when started directly from vscode!

MacOS Catalina (10.15.7)

@isometriq thank you, I tried the solution you provided, and it works!

but I had to change the inserted code, because there were some other required fields in my access table:

INSERT into access (service, client, client_type, allowed, prompt_count) VALUES ("kTCCServiceCamera","com.microsoft.VSCode",0, 1, 0);
INSERT into access (service, client, client_type, allowed, prompt_count) VALUES ("kTCCServiceMicrophone","com.microsoft.VSCode",0, 1, 0);

@Tereshka hey you're right, I add to tweak some fields and value

This'll work in the next VS Code stable release https://github.com/microsoft/vscode/issues/119787#issuecomment-810484265

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jtsom picture jtsom  路  8Comments

roblourens picture roblourens  路  7Comments

ArzelaAscoIi picture ArzelaAscoIi  路  5Comments

mgabeler-lee-6rs picture mgabeler-lee-6rs  路  4Comments

auchenberg picture auchenberg  路  3Comments