w3c / mediacapture-main

Media Capture and Streams specification (aka getUserMedia)
https://w3c.github.io/mediacapture-main/
Other
121 stars 61 forks source link

(webkit|moz)getUserMedia usage and webcompat issues #992

Closed karlcow closed 4 weeks ago

karlcow commented 6 months ago

On navigator.getUserMedia still creates webcompat issues, I was trying to understand what is the current state of implementations.

API WebKit Gecko Blink
navigator.getUserMedia undefined undefined
navigator.webkitGetUserMedia undefined undefined
navigator.mozGetUserMedia undefined undefined
navigator.mediaDevices.getUserMedia

Some bugs have been opened for Gecko and Blink to deprecate/remove the prefixed version of navigator.getUserMedia

WebKit is getting breakage because of code like

navigator.getUserMedia =
  navigator.getUserMedia ||
  navigator.webkitGetUserMedia ||
  navigator.mozGetUserMedia ||
  navigator.msGetUserMedia;

Trying to explore further the implementation history around WebKit

Some questions

The spec is currently saying:

This decision reflected consensus as long as the original API remained available here under the Navigator object for backwards compatibility reasons, since the working group acknowledges that early users of these APIs have been encouraged to define getUserMedia as "var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;" in order for their code to be functional both before and after official implementations of getUserMedia() in popular browsers. To ensure functional equivalence, the getUserMedia() method here is defined in terms of the method under MediaDevices.

fippo commented 6 months ago

Code that does look for msGetUserMedia (which was not a thing in Edge Spartan even) is doing bad things that folks in the WebRTC space agreed were for ages (2012) which led to adapter.js as something that does this kind of stuff in a more controlled fashion.

Usage for chromium is small but not zero: https://webrtchacks.github.io/chromestatus/?buckets=1401,1402 See also https://github.com/webrtcHacks/adapter/issues/764 (five years... oops)

karlcow commented 6 months ago

See also https://github.com/webrtcHacks/adapter/issues/764 (five years... oops)

Oh nooooo… ! 😭

karlcow commented 6 months ago

Usage for chromium is small but not zero: https://webrtchacks.github.io/chromestatus/?buckets=1401,1402

as of today around 0.008% of page loads. I wonder what is the opinion of @foolip on this.

fippo commented 6 months ago

That is still 4% of relative usage sadly. It isn't in video conferencing, the usage is pretty flat.

But good news, I think I figured out why people might be copy-pasting this: https://web.dev/articles/getusermedia-intro?hl=en still mentions it... that should be fixable!

eladalon1983 commented 6 months ago

@beaufortfrancois

karlcow commented 6 months ago

@samdutton would it be possible to change the article content on https://web.dev/articles/getusermedia-intro?hl=en so that the code is using the more modern API call.

beaufortfrancois commented 6 months ago

I'll be happy to update https://web.dev/articles/getusermedia-intro. Please let me know which changes you'd like to make to the article.

gsnedders commented 6 months ago

What is the usage situation for Blink, Gecko on the prefixed versions?

Note the question isn't really just about the prefixed versions; it's also about the non-standard (or at least "not normatively defined in any standard") navigator.getUserMedia.

beaufortfrancois commented 6 months ago

As discussed offline with @fippo, I'm in the process of updating https://web.dev/articles/getusermedia-intro.

beaufortfrancois commented 6 months ago

FYI https://web.dev/articles/getusermedia-intro has been updated.

fippo commented 5 months ago

https://github.com/webrtcHacks/adapter/issues/764 has been addressed by the newly published 9.0.0. How long that will take to get adopted...

jan-ivar commented 4 months ago

Firefox is blocked on essentially the same issue https://github.com/webrtcHacks/adapter/issues/1156.

foolip commented 4 months ago

Perhaps the spec should just spec these aliases conditional on https://html.spec.whatwg.org/multipage/system-state.html#concept-navigator-compatibility-mode?

aboba commented 4 weeks ago

Closing - not a spec issue.