# WebRTC facingMode environment not working in Android Chrome

**URL:** <https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187>\
**Category:** Off Topic\
**Created:** [December 26, 2020, 9:24pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187 "2020-12-26T21:24:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![xplatsolutions](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/xplatsolutions/32/939_2.png) [@xplatsolutions](https://mediasoup.discourse.group/u/xplatsolutions)\
**Post date:** [December 26, 2020, 9:24pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/1 "2020-12-26T21:24:21Z")

</div>

Having trouble figuring out why this works perfectly in Safari iOS and not Android Chrome throwing the exception `NotReadableError: Could not start video source`.  
I am closing previous track with` this.videoProducer.track.stop()`.

```
var constraints = {
    audio: false,
    video: {
        "width": {
            "ideal": 1280
        },
        "height": {
            "ideal": 720
        },
        "facingMode": {
            "exact": "environment"
        },
    },
}

const userMedia = await navigator.mediaDevices.getUserMedia(constraints) // Will throw - NotReadableError: Could not start video source

```

I also tried the constraints without width and height.

```
{
  "audio": false,
  "video": {
    "facingMode": {
      "exact": "environment"
    }
  }
}

```

Any ideas on how to debug further or try things out will be appreciated.

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [December 26, 2020, 10:50pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/2 "2020-12-26T22:50:02Z")

</div>

Have you tried to enumerate video devices and just pick another one by device ID?  
I can be up to phone vendor to mark video input devices as front/back or maybe Chrome just doesn’t support that in the first place, no idea.

---

<div class="post-metadata">

**Author:** ![xplatsolutions](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/xplatsolutions/32/939_2.png) [@xplatsolutions](https://mediasoup.discourse.group/u/xplatsolutions)\
**Post date:** [December 26, 2020, 11:00pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/3 "2020-12-26T23:00:54Z")

</div>

I did actually and will try it again but the interesting part in the Android device I test is that there are 3 devices returned where 2 are back camera!

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [December 27, 2020, 3:48am UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/4 "2020-12-27T03:48:52Z")

</div>

Yes, that is what I meant, it probably doesn’t know if those are facing front or back. But maybe it also depends on the specific phone model, I can imagine Google to put something for this to work properly on Pixel devices.

---

<div class="post-metadata">

**Author:** ![xplatsolutions](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/xplatsolutions/32/939_2.png) [@xplatsolutions](https://mediasoup.discourse.group/u/xplatsolutions)\
**Post date:** [December 27, 2020, 2:10pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/5 "2020-12-27T14:10:07Z")

</div>

I agree and this must be a phone device combination to Google Chrome issue since same phone device testing with Firefox browser actually works which is so interesting.

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [December 27, 2020, 5:43pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/6 "2020-12-27T17:43:48Z")

</div>

Looks like a good reason for upstream bug report in Chromium and post a link here if you decide to create one.

---

<div class="post-metadata">

**Author:** ![xplatsolutions](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/xplatsolutions/32/939_2.png) [@xplatsolutions](https://mediasoup.discourse.group/u/xplatsolutions)\
**Post date:** [December 27, 2020, 5:48pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/7 "2020-12-27T17:48:58Z")

</div>

Not a problem at all, could you please direct me to the correct forum?

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [December 27, 2020, 6:41pm UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/8 "2020-12-27T18:41:14Z")

</div>

Not a forum, rather [https://bugs.chromium.org/p/chromium/issues/list](https://bugs.chromium.org/p/chromium/issues/list)

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [December 28, 2020, 10:05am UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/9 "2020-12-28T10:05:11Z")

</div>

Out of curiosity, tried you code (just enveloped it in a minimal html page with video element), and it worked without a scratch both in Chrome and Firefox for Android. Android 7.1.2, Chrome 87.0.4280.101, Firefox 84.1.1

By the way, I have an old HP notebook with Windows 8.1 and some obscure problem with a built-in microphone, and sometimes Chrome issues very similar error, only for the audio device (‘Could not start audio source’). In Firefox it is either working at the same time or not - it depends. The error is cured only by the computer restart. So you problem can very easily be hardware.

---

<div class="post-metadata">

**Author:** ![xplatsolutions](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/xplatsolutions/32/939_2.png) [@xplatsolutions](https://mediasoup.discourse.group/u/xplatsolutions)\
**Post date:** [December 30, 2020, 11:56am UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/10 "2020-12-30T11:56:15Z")

</div>

I have a Galaxy A20s Android 10 with Chrome 87.0.4280.101 and Firefox 84.1.2.

I assume you comparing the audio issue and your machine hardware issue with my phone hardware which yes could be a phone issue, I will need to test it with another device.

---

<div class="post-metadata">

**Author:** ![hdoru](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/hdoru/32/696_2.png) [@hdoru](https://mediasoup.discourse.group/u/hdoru)\
**Post date:** [December 31, 2020, 7:20am UTC](https://mediasoup.discourse.group/t/webrtc-facingmode-environment-not-working-in-android-chrome/2187/11 "2020-12-31T07:20:07Z")

</div>

> [@xplatsolutions](#):
>
> ```auto
> "video": {
> "facingMode": {
> "exact": "environment"
>     
> 
> ```

```auto
"video": {
    "facingMode": "user" or "environment"
} 

```

would you use it that way? On some devices, the face recognition sensor comes as a camera.
