mediacapture-main icon indicating copy to clipboard operation
mediacapture-main copied to clipboard

(webkit|moz)getUserMedia usage and webcompat issues

Open karlcow opened this issue 11 months ago • 13 comments

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

  • What is the usage situation for Blink, Gecko on the prefixed versions?
  • Is their will to remove them soonish? (and do site interventions at least for Gecko)
  • Or was there attempt to remove that were reverted because of compat issues?

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.

karlcow avatar Mar 06 '24 02:03 karlcow

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)

fippo avatar Mar 06 '24 06:03 fippo

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

Oh nooooo… ! 😭

karlcow avatar Mar 06 '24 07:03 karlcow

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.

karlcow avatar Mar 06 '24 07:03 karlcow

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!

fippo avatar Mar 06 '24 15:03 fippo

@beaufortfrancois

eladalon1983 avatar Mar 06 '24 15:03 eladalon1983

@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.

karlcow avatar Mar 07 '24 03:03 karlcow

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.

beaufortfrancois avatar Mar 07 '24 08:03 beaufortfrancois

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.

gsnedders avatar Mar 07 '24 12:03 gsnedders

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

beaufortfrancois avatar Mar 08 '24 10:03 beaufortfrancois

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

beaufortfrancois avatar Mar 08 '24 16:03 beaufortfrancois

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...

fippo avatar Mar 27 '24 02:03 fippo

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

jan-ivar avatar Apr 16 '24 14:04 jan-ivar

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

foolip avatar Apr 16 '24 15:04 foolip

Closing - not a spec issue.

aboba avatar Aug 08 '24 14:08 aboba