[mediacapture-screen-share] getUserMedia media streams capturing issue in MV3 (chrome extension) with respect to constraints (#299)

Nitesh2503 has just created a new issue for https://github.com/w3c/mediacapture-screen-share:

== getUserMedia media streams capturing issue in MV3 (chrome extension) with respect to constraints ==
### Bug Description
When using the `getUserMedia` API in Chrome to capture audio from specific Chrome tabs using the `chromeMediaSource` and `chromeMediaSourceId` constraints, the API is not behaving consistently. The issue manifests as the error "Uncaught (in promise) DOMException: Invalid state error."

### To Reproduce
Steps to reproduce the behavior:

Get the streamId from the `desktopCapture` API
```
chrome.desktopCapture.chooseDesktopMedia(
      ["tab", "audio"],
      tab,
      (streamId, options) => {});
```
Here, tab` argument consists of the tab info

Use the `getUserMedia` API to get the streams
```
navigator.mediaDevices.getUserMedia({
  audio: {
    mandatory: {
      chromeMediaSource: "desktop",
      chromeMediaSourceId: streamId,
    },
  },
  video: {
    optional: [],
    mandatory: {
      chromeMediaSource: "desktop",
      chromeMediaSourceId: streamId,
    },
  },
}).then((streams)=>{});
```
Here, the "Uncaught (in promise) DOMException: Invalid state error." will occur

### Expected behavior
The `getUserMedia` API should consistently capture audio from Chrome tabs using the specified `chromeMediaSource` and `chromeMediaSourceId` constraints without resulting in an "Invalid state error."

### Screenshots
These are the expected beahavior :
![image](https://github.com/w3c/mediacapture-screen-share/assets/72183768/a2bc853e-6014-43f0-bf53-35bca3e811a0)

![image](https://github.com/w3c/mediacapture-screen-share/assets/72183768/5e8a8e7a-93b7-44a6-b085-2364aa33a973)

### Desktop
OS : iOS
Browser : chrome
Version : 119.0.6045.199
Additional context
I am working on the chrome extension (Manifest Version-3) so using the getUserMedia API to get the streams from the particular streamId and as mentioned above facing the Issues while capturing the media.

For reference use the below doc for more info on the errors for the different constraints of the getUserMedia API tried
[getUserMedia-DOC](https://docs.google.com/document/d/1CQXxIqrd5WS0sDzHr5douaino35Iwm8aq7cQLn7-HFc/edit)

Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/299 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 27 February 2024 10:09:52 UTC