Bug 188360

Summary: mediaDevices in WKWebview is undefined
Product: WebKit Reporter: Mike Hartington <mikehartington>
Component: WebRTCAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: alejandro.silva, beidson, bernie, bill, bugmail, daginge, eelco, elitree, eric.carlson, feross, flagworlds1, jer.noble, juliosincesar, marcel, molnar.timi7, ramanaedwin, shahraship, silviapfeiffer1, stefan, tomac, vitalyd87, webkit-bug-importer, webkit, will.morgan, wvsmlmdiaaxvhkrqov, youennf, znelson
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: iPhone / iPad   
OS: Other   

Description Mike Hartington 2018-08-06 14:34:08 PDT
Inside of WKWebview, mediaDevices and getUserMedia are not implemented, but are there in Webkit/Safari.

var videoTag = document.querySelector('video');
var getVideoStream = function() {
    .getUserMedia({ video: true })
    .then(streamRes => (videoTag.srcObject = streamRes));
Comment 1 jcesarmobile 2019-10-23 08:36:59 PDT
Any plans on adding this? WKWebView apps are very limited without this kind of features that are already in Safari.
Comment 2 Radar WebKit Bug Importer 2019-10-23 09:26:43 PDT
Comment 3 Jerome @ Neareo 2020-02-17 23:57:34 PST
We have a html-based chatbot platform that requires a QR scanner. We urgently need WebRTC (getUserMedia) to work in apps using WKWebView.

I've seen that SFSafariViewController is now working with iOS 13. Any plans to support getUserMedia in WKWebView ?
Comment 4 Alejandro Silva 2020-02-27 07:00:11 PST
Hi! I've read something about getting released in iOS 13.4. Can you deny/confirm it? Thank you so much!
Comment 5 krak1 2020-05-07 06:53:45 PDT
I really don't like you apple. You don't deserve the number of customers you have. Fix it quickly!
Comment 6 zn 2020-05-11 01:24:32 PDT
I can’t even describe how infuriating it is that getUserMedia and thus WebRTC isn’t supported. So many things are much easier to implement in JavaScript when it comes to WebRTC instead of jumping through a million hoops in Obj-C and the garbage environment that is iOS native. Apple is ridiculous.
Comment 7 Mike Hartington 2020-05-11 06:41:26 PDT
Let's keep comments professional and civil folks.
Comment 8 daginge 2020-07-24 01:44:27 PDT
With the advent of new default browsers in iOS 14, this will become a bigger UX problem for WebRTC services. I have tested iOS 14 Developer Beta 3, and neither Chrome nor Firefox can complete a simple getUserMedia call (fails with TypeError in samples).

Since users now can select these browsers as default, WebRTC services must implement specific UX to teach users how to copy the link, change to Safari, and open it in Safari for WebRTC to work.

Having support for getUserMedia/WebRTC in WKWebView is now critical for WebRTC as a whole on iOS. Users won't be able to understand why their default browser does not support WebRTC.

Are there any details to share on the timeline for support, or are there talks with browser vendors to avoid this problem? What should us application developers do?
Comment 9 molnar.timi7 2020-07-24 15:18:13 PDT
Finally there is a solution! Check this comment: https://bugs.webkit.org/show_bug.cgi?id=183201#c31

There is a brand new WebRTC library for WKWebView, and it works like a charm! https://github.com/OpenTelecom/WKWebViewRTC
Comment 10 Silvia Pfeiffer 2020-07-29 00:36:57 PDT
It would be really good to have WKWebView support getUserMedia for pwa - is getUserMedia functionality planned to be available for WKWebView?
Comment 11 Vitalii 2021-12-09 01:52:57 PST
In Info.plist add:
`Privacy - Camera Usage Description`

And in order video element could play from your camera:
let webConfiguration = WKWebViewConfiguration()
webConfiguration.allowsInlineMediaPlayback = true

How to play: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Comment 12 youenn fablet 2021-12-09 02:50:20 PST
Marking as configuration changed now that getUserMedia is exposed in WKWebView.