nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

mediaDevices.enumerateDevices broken in iframe

Open escatg opened this issue 6 years ago • 4 comments

NWJS Version : from 0.45.2 -> 0.48.1 Operating System : reproduced on Linux and Windows 10

Expected behavior

It should be possible to get a complete list of media devices by calling navigator.mediaDevices.enumerateDevices() after obtaining permission from navigator.mediaDevices.getUserMedia().

Actual behavior

In the iframe, the list of media devices returned is incomplete and contains no label and no deviceId, as if we didn't have the permission to list media devices.

How to reproduce

  • Upgrade to nw.js >= 0.45.2 (worked fine before).
  • Run the attached code mediadevices_test.zip
  • Application will open showing a complete media device list in the main window and an incomplete one in the iframe.

expected output

Partial workaround: adding --use-fake-ui-for-media-stream in chromium_flags allows it to work again in iframe, but other things break like screen sharing. Just tested with --disable-features=nw2 which also seems to restore expected behavior in iframe.

escatg avatar Sep 07 '20 12:09 escatg

Linking to #7230

escatg avatar Sep 07 '20 13:09 escatg

In NW2 there is better control for device access. You are loading code from remote domain in iframe to access local devices, which is blocked by default. This can be allowed by using chrome.contentSettings api .

So close as a non-issue for now.

rogerwang avatar Sep 27 '20 08:09 rogerwang

For the record, regardeless of the Chrome extenion contentSettings, you need to add --use-fake-ui-for-media-stream to chromium-args properly get the devices name in enumerateDevices()

bschmitlin avatar Oct 12 '20 13:10 bschmitlin

I have the same problem. Same scenario but NWJS version 0.52.2

In order to get the devices name --use-fake-ui-for-media-stream is needed in chromium_flags but then screenSharing is not correctly working. getDisplayMedia is returning a DOMException: Could not start video source.

Am I missing something?

monema75 avatar Jan 28 '22 15:01 monema75