Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When webpage tries to access cam or microphone it asks for user permission #7229

Closed
krneticz opened this issue Nov 21, 2019 · 18 comments
Closed

Comments

@krneticz
Copy link

NWJS Version : 0.42.5
Operating System : Windows

Expected behavior

When loaded webpage tries to access cam or microphone no user permission is requested. This is how it worked in older nwjs e.g. in 0.40.2 (did not try all releases between 0.40.2 and 0.42.5, but it did not ask for permission in 0.41.3).

Actual behavior

When loaded webpage tries to access cam or microphone it asks for user permission. This is a problem for us at seeyoulink.com, since we are making software for seniors, disabled and tech-illiterate, so this extra step of approval is very hard for them and most of them won't be able to approve properly or will get confused.

How to reproduce

Load any page that uses webcam and microphone e.g. https://webcammictest.com/

@Jip-Hop
Copy link

Jip-Hop commented Nov 25, 2019

There was the Chrome flag --unsafely-allow-protected-media-identifier-for-domain=localhost that could be used for this...

For automated testing of protected content, this switch allows specific domains (e.g. example.com) to skip asking the user for permission to share the protected media identifier. In this context, domain does not include the port number. User's content settings will not be affected by enabling this switch. Reference: http://crbug.com/718608 Example: --unsafely-allow-protected-media-identifier-for-domain=a.com,b.ca ↪

but it seems this flag no longer works. I get the following message when running Chrome like this:

You are using an unsupported command-line flag: Stability and security will suffer.

@krneticz
Copy link
Author

Yes, I confirm that flag does not work. However in older nwjs versions, flag was not needed anyway (e.g. in 0.41.3)

@Jip-Hop
Copy link

Jip-Hop commented Nov 25, 2019

How about this flag:

-–use-fake-ui-for-media-stream.

Could work for local files served over file:// protocol as I understand it.

Reference here.

@krneticz
Copy link
Author

--use-fake-ui-for-media-stream doesn't help either. @rogerwang is there a chance you can take a look at this issue within the next two weeks?

Thanks!

@Jip-Hop
Copy link

Jip-Hop commented Nov 26, 2019

Ah yes, seems that wasn't it either. But for me this works:

package.json

{
  "name": "webcamtest",
  "version": "1.0.0",
  "description": "webcamtest",
  "main": "webcamtest.html",
  "build": {
    "nwVersion": "0.42.5"
  },
  "dependencies": {},
  "author": "",
  "license": "ISC"
}

webcamtest.html

<!DOCTYPE html>
<html>

<head>
    <title>Webcam test</title>
    <style>
        html, body, iframe {
            width: 100vw;
            height: 100vh;
        }

        * {
            margin: 0;
            padding: 0;
            border: 0;
        }
    </style>
</head>

<body>
    <iframe allow="camera; microphone" src="https://www.cam-recorder.com/"></iframe>
</body>

</html>

@rogerwang
Copy link
Member

rogerwang commented Nov 26, 2019 via email

@rogerwang rogerwang self-assigned this Nov 26, 2019
@rogerwang
Copy link
Member

For now you can use --disable-features=nw2 as workaround.

@krneticz
Copy link
Author

@rogerwang thank you very much! We really appreciate your commitment to this awesome project.

@krneticz
Copy link
Author

BTW --disable-features=nw2 doesn't help. It prevents showing consent to user, but the cam and microphone does not work when used.

@rogerwang
Copy link
Member

The switch works for me — I tested the website and the webcam works with the switch.

@krneticz
Copy link
Author

You are right! I re-tested and it works with --disable-features=nw2. Was my mistake...

@krneticz
Copy link
Author

@rogerwang just so that I can plan our release, do you know when fix for this is supoosed to be released? Thanks!

@rogerwang
Copy link
Member

@krneticz as the nw1 mode is working, I'm planning a real fix for this in nw2 mode. It would include a new API with which the app's code can control whether it's enabled or not on the fly. The webcam and microphone should not be enabled by default. Currently I don't have any schedule for it.

@krneticz
Copy link
Author

@rogerwang makes sense. Thanks for the quick response!

@rogerwang
Copy link
Member

This blocks #7230

@rogerwang
Copy link
Member

This is fixed in git and will be available in the next nightly build.

@rogerwang
Copy link
Member

Ref #6492

@runekaagaard
Copy link

For me tested on Ubuntu 20.04 with the v0.73 sdk release i still need both:

document.getElementById("MYWEBVIEW").addEventListener('permissionrequest', function permissionRequest(e) {
  e.request.allow();
})

and

./nw --disable-features=nw2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants