dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
9.94k stars 1.53k forks source link

HTML camera bindings need to be updated for firefox #35253

Open robertmuth opened 5 years ago

robertmuth commented 5 years ago

dart --version Dart VM version: 2.2.0-dev.0.0 (Unknown timestamp) on "linux_x64"

Old transpiled code is now broken and re-transpiling with the new sdk does not fix the problem.

I see the following warning: navigator.mozGetUserMedia has been replaced by navigator.mediaDevices.getUserMedia

but I think the real issue is that videoElem.mozSrcObject = stream; needs to change to videoElem.srcObject = stream;

https://github.com/ChronosTeam/ChronosGL has several reproducers in example/camera*

natebosch commented 4 years ago

We are missing a couple APIs from MediaDevices, getUserMedia and getDisplayMedia. Otherwise I think we are good with Navigator.mediaDevices.

evasilova commented 4 years ago

Thanks Nate! Just a note: Navigator.getUserMedia is deprecated, which is probably why the warning mentioned in the original comment was displayed.

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia

srujzs commented 4 years ago

Re: missing APIs, MediaDevices.getUserMedia was suppressed in the last IDL roll: https://github.com/dart-lang/sdk/blob/master/tools/dom/idl/dart/dart.idl#L320. I talked to @terrylucas and it seems like it was suppressed due to lack of support for Promise, which has been fixed, so hopefully the fix might be to just remove that and see what the scripts generate.

As for getDisplayMedia, it wasn't introduced in Chrome until version 72, and our IDLs are from 63.

robertmuth commented 4 years ago

Nice to see some activity on this bug - I had sort of given up on dart for html. Is there a timeframe for upgrading the idl ? Chrome 63 was released end of 2017.

srujzs commented 4 years ago

Unfortunately, due to how much work it will take, there isn't a plan currently for upgrading/rolling the IDL. Sorry about that. We want to migrate to a different model using the generated DOM in TypeScript instead, but that's still in a preliminary stage.

robertmuth commented 4 years ago

There are a few other long-standing bugs that might also be fixable without rolling the IDLs:

gamepad bindings https://github.com/dart-lang/sdk/issues/33148

midi bindings https://github.com/dart-lang/sdk/issues/33248

speech synthesis bindings https://github.com/dart-lang/sdk/issues/33178

Last time I tried (6-12 month ago) I could not get services workers to run either but I have not confirmed this lately.

srujzs commented 4 years ago

Thanks for sharing! We're looking to triage these and other outstanding HTML bugs so we can address them soon.

odogy commented 4 years ago

I've run into this issue because Safari, which I think added support for this only somewhat recently, has implemented navigator.mediaDevices.getUserMedia, but not navigator.getUserMedia. I'm having a tough time figuring out how to add support for this through Dart's JS interop.

robertmuth commented 4 years ago

@srujzs

Any update? This bug is soon celebrating its 18 months anniversary.

srujzs commented 4 years ago

No, not yet, sorry. I've been focusing largely on the null safety release; we haven't gotten the opportunity to sit down and triage/tackle some of these bugs. Since this looks like a simple un-suppressing, I'll take a stab at it and report back soon.

srujzs commented 4 years ago

MediaDevices.getUserMedia has been landed. @robertmuth, is there anything left in this issue that hasn't been addressed/discussed?

romatroskin commented 3 years ago

seems like MediaDevices.getUserMedia ignores constraints at all, as well as MediaStreamTrack.applyConstraints, used to write interop to test, and with interop it's working as well, but not with provided dart:html method :(

romatroskin commented 3 years ago

Yep, looks like something wrong with convertDartToNative_Dictionary, because I've forked the engine, changed this method to convertDartToNative_SerializedScriptValue and tried to run with this changes, and now everything works like a charm, and there is a lot of places using convertDartToNative_Dictionary that's mean we have a lot of places with the issues at the moment :(

srujzs commented 3 years ago

seems like MediaDevices.getUserMedia ignores constraints at all

Hmm, I don't believe I'm seeing this locally. Changing the constraints between {'audio': true} and {'video': true} triggers Chrome to ask for microphone or camera access, respectively. Can you file a separate issue and provide a small repro for the issue you are seeing? Thanks!

romatroskin commented 3 years ago

there is already opened separated issue #43802 and yes, its happening and really critical because it's not possible to switch or specify camera and turn on/off torch from which I've noticed the issue and already fixed locally

NickCarducci commented 2 years ago

add its deviceId to the MediaConstraints object that eventually gets passed into getUserMedia()

Are you sure this is a dart problem? If I'm switching {'audio': true} and {'video': true} and back, my user already knows the confirm answer