webrtc / samples

WebRTC Web demos and samples
https://webrtc.github.io/samples
BSD 3-Clause "New" or "Revised" License
13.94k stars 5.71k forks source link

Video Analyzer doesn't work on http/default server settings #1621

Open hamishwillee opened 1 year ago

hamishwillee commented 1 year ago

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed.

Browser affected

Firefox 119.0a1, Chrome

Description

Video Analyzer (and probably others) apply transforms to local media (i.e. webcam). The webcam can only be requested in a secure context on all recent browsers, while http-server is not configured to work with https by default.

What this means is that you can't easily test the samples locally without modification.

The desired result is that is it is easy to try out these examples and that they reflect the current standards.

Steps to reproduce

Run src/content/insertable-streams/video-analyzer/ locally following the readme instructions.

Expected results

YOu are prompted to use webcam, then frame rates etc are reported.

Actual results

You will not be prompted to get access to webcam. The example effectively stalls since HTTPS does not work, you don't get the webcam, frames aren't provided.

I reset to the latest chrome and the example to latest gh-pages head revision and got this result on pressing the "Call" button.

image

hamishwillee commented 1 year ago

When these samples were written, "localhost:" was treated as a trusted context by Chrome. Has that changed?

@alvestrand This is the bug spawned off #1620

I don't know "for sure" if Chrome is treating localhost as trusted, but it looks like not: https://chromestatus.com/feature/6269417340010496 - and that is how I interpret the fact that this works if I install a certificate and serve as HTTPS.

Edit: Note, the title was wrong/issue is not localhost - the issue is that the server does not allow testing in a secure context by default

fippo commented 1 year ago

But you are running on 192.168.56.1 in the screenshot which isn't localhost? TypeError is what is returned when there is no navigator.mediaDevices which is only available when window.isSecureContext is true.

hamishwillee commented 1 year ago

@fippo Apologies. The description was OK but the title is not. The issue is that the server test urls are all http - to test this you do need a secure context, so you can't test the samples out of the box.