Search code examples
javascriptgoogle-chromefirefoxpromisewebcam

Firefox never resolving navigator.mediaDevices.getUserMedia()


I am trying to use the new Promise-based WebRTC/Media tools, to get feedback if the user allowed access to the camera and/or microphone as documented here https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

The following code-snippet, simply injected with the browser's developer tools, does never fullfill the Promise on Firefox when access is granted, yet on Chrome it works as expected.

(tested with Firefox 53 32-bit, Chrome 59 64-bit)

navigator.mediaDevices.getUserMedia({
        "audio": true, 
        "video": true
    })
      .then(() => console.log("OK!"))
      .catch(() => console.log("NOPE"))

It appears that the Promise is pending forever.

Steps to reproduce:

  1. open any https encrypted page (so firefox doesnt complain about that)
  2. open the developer tools, get to the console
  3. paste the code snippet from above
  4. allow camera/microphone access in the popup
  5. nothing

Is this a bug in Firefox or is something wrong with the code snippet? To comply with the MDN documentation, i've also tried to use the good'ol functions instead of ES6 arrow functions - with the same effect.


Solution

  • After disabling all addons (especially NoScript - even after setting "scripts globally allowed" to true) it appears to run just fine.

    Sorry for the unnecessary question then, i guess, and thanks for reconfirming me, that the problem was not Firefox itself, so got on the right track to find the solution!