mediacapture-main
mediacapture-main copied to clipboard
(webkit|moz)getUserMedia usage and webcompat issues
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
- Gecko Deprecate navigator.mozGetUserMedia(). It didn't happen yet.
- Blink Remove navigator.webkitGetUserMedia, Deprecate navigator.getUserMedia()
- seeAlso WPT for not supporting it
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
- Apr 2011: Media Stream API: add the getUserMedia method and the Javascript bindings. This was adding in fact
navigator.webkitGetUserMedia
- Some back and forth for implementing, adjustment to match spec changes.
- Apr 2015: Support for
navigator.mediaDevices.getUserMedia()
- Jun 2016: getUserMedia() exposed, but not functional
- Feb 9, 2017:[MediaStream] Remove legacy Navigator.webkitGetUserMedia
- Feb 14, 2017: [MediaStream] add navigator.getUserMedia for compatibility with legacy content
- Aug 2018: Remove WebRTC legacy API implementation
- Mar 2020: navigator.getUserMedia is not available in WKWebView iOS 13.4 beta 4
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?
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.
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)
See also https://github.com/webrtcHacks/adapter/issues/764 (five years... oops)
Oh nooooo… ! 😭
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.
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!
@beaufortfrancois
@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.
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.
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
.
As discussed offline with @fippo, I'm in the process of updating https://web.dev/articles/getusermedia-intro.
FYI https://web.dev/articles/getusermedia-intro has been updated.
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...
Firefox is blocked on essentially the same issue https://github.com/webrtcHacks/adapter/issues/1156.
Perhaps the spec should just spec these aliases conditional on https://html.spec.whatwg.org/multipage/system-state.html#concept-navigator-compatibility-mode?
Closing - not a spec issue.