webrtcHacks / adapter

Shim to insulate apps from spec changes and prefix differences. Latest adapter.js release:
https://webrtcHacks.github.io/adapter/adapter-latest.js
BSD 3-Clause "New" or "Revised" License
3.61k stars 845 forks source link

TypeError navigator.mediaDevices is undefined, at shimGetUserMedia #1022

Open PavMel opened 4 years ago

PavMel commented 4 years ago

Please read first!

Please use discuss-webrtc for general technical discussions and questions.

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

Versions affected

Browser name: Chrome Version:75.0.3770 and others, probably spoofed

adapter.js 7.5.0

Description

TypeError navigator.mediaDevices is undefined I using sentry for handling errors: image

Steps to reproduce

Is happened on real traffic

Expected results

No errors

Actual results

TypeError navigator.mediaDevices is undefined Script stopped working because import error

import adapter from "webrtc-adapter" 
import "detectrtc"                                 // <== other lib
fippo commented 4 years ago
src/js/firefox/getusermedia.js:    const nativeGetUserMedia = navigator.mediaDevices.getUserMedia.

is the only nativeGetUserMedia I see so its probably spoofing combined with some kind of privacy extension. @jan-ivar wanna take a stab?

jan-ivar commented 4 years ago

navigator.mediaDevices is undefined in http. Could that be it?

fippo commented 4 years ago

I checked http and there adapters browser detection for Firefox is broken even. Whoops... relies on mozGetUserMedia. Maybe better to rely on mozRTCPeerConnection instead?

fippo commented 4 years ago

I think shimGetUserMedia should simply check for mediaDevices in navigator and if its not there return.

fippo commented 4 years ago

oh hold on. The error is inside this block:

  if (!(browserDetails.version > 55 &&
      'autoGainControl' in navigator.mediaDevices.getSupportedConstraints())) {

so how can it throw?

jan-ivar commented 4 years ago

browserDetails.version > 55 is presumably true, and undefined.getSupportedConstraints is a TypeError?

jan-ivar commented 4 years ago

relies on mozGetUserMedia. Maybe better to rely on mozRTCPeerConnection instead?

No, we're likely to deprecate mozRTCPeerConnection before we deprecate mozGetUserMedia.

They may both go away eventually though.

Mazuh commented 4 years ago

I was having this error due to my app being exposed on HTTP (instead of HTTPS). Does someone agree that we should polyfill this with Promise rejections? Or is it too much out of scope? :thinking: Just having it undefined is weird!

fippo commented 4 years ago

that would break feature detection - if it was a good idea then the browser vendors would have done it.

jan-ivar commented 4 years ago

Yes, this is intentional for feature detection. In fact on Android, Firefox and Chrome are going the other way: leaving it undefined even in https, to not signal support on those platforms when there is none.

ankushswoopos7 commented 3 years ago

Unable to connect to Room: getUserMedia is not supported whenever i am running in http://192.168.0.56:8000/ (local IP)

fippo commented 3 years ago

getUserMedia has not been supported on HTTP for a while with the exception of localhost since 2015: https://developers.google.com/web/updates/2015/10/chrome-47-webrtc?hl=en

benja-M-1 commented 3 years ago

I don't user adapter.js. However, I stumbled uppon this issue while googling about a similar issue I have and I can't figure out why this happens (I don't expect you to solve mine, I just provide some information that seems useful for you). undefined is not an object (evaluating 'navigator.mediaDevices.enumerateDevices')

I am 100% sure that it happens on https URL as we only serve https. Here is the list of the user agents for which the error happened

fippo commented 3 years ago

that sounds like chrome on ios which, being wkwebview-based didn't have getUserMedia. Check support before using it.

benja-M-1 commented 3 years ago

Yes you are right sorry for the noise... and thank you very much for your answer