desktopCapturer.getSources and getUserMedia not working

1.3k views Asked by At

I've an Electron app that uses desktopCapturer, and I also capture audio using getUserMedia.

All this works well when in development. But after building the app using electron-builder for Mac (dmg),

  1. desktopCapturer's getSources only returns the electron app and desktop's thumbnails as the sources, all other windows' thumbnails are not returned (even though their titles are).

  2. I also keep getting asked if I should allow the app to record screen, even when in settings > screen recording, the app has been allowed. (Maybe it keeps asking for audio? Even so, how to allow the app record audio?)

  3. I'm also not able to record any audio, but while in development, I was able to.

  4. The app also is no longer able to record from camera saying getUserMedia error: NotReadableError: Could not start video source electron - even when no other app is using the camera.

I'm completely lost as to were the problem is or how to debug this. Any help is appreciated!

1

There are 1 answers

1
tweedleDee On

I have found that I have to remove and regrant permissions in system preferences after building a new version of the app (and restart the app for them to take affect).

If that doesn't work you may need to add/edit a build/entitlements.mac.inherit.plist. Its talked about as a requirement for electron builder here:https://www.electron.build/configuration/mac.html#:~:text=to%20application%20icon.-,entitlements,-String%20-%20The%20path

I think it should look something like this:

  <?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.device.audio-input</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
  </dict>
</plist>