adapter icon indicating copy to clipboard operation
adapter copied to clipboard

TypeError navigator.mediaDevices is undefined, at shimGetUserMedia

Open PavMel opened this issue 5 years ago • 15 comments

Please read first!

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

  • [x] I have provided steps to reproduce (e.g. a link to a jsfiddle)
  • [x] I have provided browser name, version and adapter.js version
  • [x] This issue only happens when adapter.js is used

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

PavMel avatar Feb 25 '20 23:02 PavMel

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?

fippo avatar Feb 26 '20 17:02 fippo

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

jan-ivar avatar Feb 27 '20 01:02 jan-ivar

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 avatar Feb 27 '20 18:02 fippo

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

fippo avatar Feb 27 '20 18:02 fippo

oh hold on. The error is inside this block:

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

so how can it throw?

fippo avatar Feb 27 '20 18:02 fippo

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

jan-ivar avatar Feb 27 '20 18:02 jan-ivar

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.

jan-ivar avatar Feb 27 '20 18:02 jan-ivar

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!

Mazuh avatar Mar 28 '20 21:03 Mazuh

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

fippo avatar May 15 '20 12:05 fippo

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.

jan-ivar avatar May 15 '20 14:05 jan-ivar

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

ankushswoopos7 avatar Feb 22 '21 09:02 ankushswoopos7

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

fippo avatar Feb 22 '21 10:02 fippo

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

  • mac OS 1.15
    • Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15
  • iPad
    • Mozilla/5.0 (iPad; CPU OS 9_3_5 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13G36 Safari/601.1
    • Mozilla/5.0 (iPad; CPU OS 12_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPad; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPad; CPU OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPad; CPU OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1
  • iPhone
    • Mozilla/5.0 (iPhone; CPU iPhone OS 12_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/90.0.4430.78 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.163 Mobile/15E148 Safari/604.1
    • Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/137.2.345735309 Mobile/15E148 Safari/604.1

benja-M-1 avatar May 20 '21 21:05 benja-M-1

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

fippo avatar May 21 '21 05:05 fippo

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

benja-M-1 avatar May 22 '21 09:05 benja-M-1