8000 getUserMedia(mediaConstraints) does not consider deviceId and always open the default camera · Issue #43802 · dart-lang/sdk · GitHub
[go: up one dir, main page]

Skip to content

getUserMedia(mediaConstraints) does not consider deviceId and always open the default camera #43802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wer-mathurin opened this issue Oct 15, 2020 · 8 comments
Assignees
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. library-html web-libraries Issues impacting dart:html, etc., libraries

Comments

@wer-mathurin
Copy link

When you pass the constraint to the getUserMedia(mediaConstraints), it always open the default camera and do not considerer the deviceId pass in the constraints. To test this you can change the default camera in Chrome and you will see that It will open the default one.

var mediaConstraints = <String, dynamic>{
          'audio': true,
          'video': {'deviceId': [SOME_DEVICE_ID]}
        };

This tracker is for issues related to:
dart2js

Dart SDK Version (dart --version)
Dart SDK version: 2.10.1 (stable) (Tue Oct 6 10:54:20 2020 +0200) on "windows_x64"

Whether you are using Windows, MacOSX, or Linux (if applicable)
Windows

Whether you are using Chrome, Safari, Firefox, Edge (if applicable)
Chrome

@wer-mathurin
Copy link
Author

The problem come from constraints parameter is converted to JS object using convertDartToNative_Dictionary which does not work recursive as you can see in its implementation.

@a-siva a-siva added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Oct 19, 2020
@romatroskin
Copy link
romatroskin commented Nov 10, 2020

do you have some ETA for this fix? using convertDartToNative_SerializedScriptValue instead works fine

@romatroskin
Copy link
romatroskin commented Nov 10, 2020

same problem was noticed for MediaStreamTrack.applyConstraints() also and I believe there is much more broken APIs like these ones according to this issue :(

@srujzs srujzs added library-html web-libraries Issues impacting dart:html, etc., libraries labels Nov 10, 2020
@srujzs srujzs self-assigned this Nov 10, 2020
@srujzs
Copy link
Contributor
srujzs commented Nov 10, 2020

Talked this over a bit. cc @sigmundch @rakudrama

convertDartToNative_Dictionary is indeed non-recursive, which means if we support recursive maps like in the example, we need a separate method to copy recursively. As a workaround for your purposes, you can import dart:html_common and use convertDartToNative_SerializedScriptValue to convert the map before calling the API. Replacing convertDartToNative_Dictionary with this method wholesale isn't ideal since it overloads that method, and it may not handle types that are not clone-able properly. I think we would want a method that recursively copies a map while ignoring types that aren't a map and use that instead.

I believe there is much more broken APIs

This is possible, can you point to the other ones you're coming across? It would be very useful to understand where recursive maps can be expected but aren't. Thanks!

@wer-mathurin
Copy link
Author

Hi @srujzs

The only one I'm think about right now:
addStream

dart-bot pushed a commit that referenced this issue Nov 16, 2020
Bug: #43802

convertDartToNative_Dictionary relied on the input being flat, which
failed since it was being used for some APIs which allowed for nested
dictionaries. Modifies it so that it converts any map or list values
in the provided map.

Change-Id: I9a404f4cd1f582cd88d43a57fbee0e07b0ee7e76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171805
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
@srujzs
Copy link
Contributor
srujzs commented Nov 18, 2020

convertDartToNative_Dictionary has been changed to be recursive, but only handles anything that doesn't need a conversion, maps, and lists. This should cover the above APIs.

@HidalgoIvan
Copy link

I am having the same problem, I'm defining the map itself explicitly without any methods or references and it still does not load the desired camera:

{ "video": {"deviceId": "0"}, "audio": false }

@srujzs
Copy link
Contributor
srujzs commented Mar 22, 2023

That map is recursively copied as expected when I try it locally. Is the deviceId of the camera you're expecting 0 and is some other camera being loaded instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. library-html web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

5 participants
0