adapter icon indicating copy to clipboard operation
adapter copied to clipboard

Chrome will be identified as Safari if webkitGetUserMedia is removed

Open foolip opened this issue 7 years ago • 14 comments

A continuation of https://github.com/webrtc/adapter/issues/712, or a subset thereof. After some changes this is the remaining problematic code: https://github.com/webrtc/adapter/blob/0a293a9803dcd612cb73c147218a81d56405d6bd/src/js/utils.js#L151

This is probably blocking https://bugs.chromium.org/p/chromium/issues/detail?id=692736, as being identified as Safari might have other consequences.

foolip avatar Jan 31 '18 11:01 foolip

What about using something unique instead of a related WebRTC Api like getUserMedia?

Like window.chrome ?

KaptenJansson avatar Mar 08 '18 09:03 KaptenJansson

@fippo @alvestrand

KaptenJansson avatar Mar 08 '18 09:03 KaptenJansson

I've run into this issue as well when trying to use this library for an app that I want to run on mobile. The browser when running on Chrome for iOS is being read as Safari version 604. Can /Chrome/ be read in from the User Agent with something like navigator.userAgent.match(/Chrom(e|ium)\/(\d+)\./))?

Otherwise, this is a really helpful library! thanks a bunch, all!

rtzm avatar Mar 18 '18 19:03 rtzm

@rtzm but in that case you want the shim code to be the safari shim even though it is chrome?

@KaptenJansson hrm... how does that behave in chrome on ios?

fippo avatar Mar 18 '18 19:03 fippo

I just manually tested window.chrome and window.chrome.webstore on chrome for iOS, and both are undefined, although both should work for Chrome for desktop. Made a PR to add this feature detection here.

It also looks like detecting the correct method for getUserMedia on Chrome for iOS is moot, because iOS 11 doesn't allow Chrome to implement WebRTC: http://www.openradar.me/33571214.

rtzm avatar Mar 22 '18 01:03 rtzm

@rtzm all browser on iOS are built on top of (WKWebVIew with) Apple's WebKIt engine. Sadly, all Chrome has is a nice wrapped package for us. that's it. (see Google's past announcement)

So where getUserMedia() works on Safari, it's still blocked on WKWebView..

zaxy78 avatar Mar 22 '18 19:03 zaxy78

window.chrome.webstore does not work in Brave unfortunately which supports RTCPeerConnection (and is, no surprise, using the chrome version. And just checking for window.chrome yields true in Edge :-(

fippo avatar Mar 22 '18 19:03 fippo

haha, ok, closing my PR, since it looks like this won't be moving forward this way ¯_(ツ)_/¯

rtzm avatar Mar 23 '18 01:03 rtzm

wondering if just window.chrome is a good way to identify chrome. This would cover chrome, opera and brave at least.

@foolip do you know if there is any description of window.chrome?

fippo avatar Apr 11 '18 11:04 fippo

Someone mentioned window.chrome exists in Edge too

On Wed, Apr 11, 2018, 14:57 Philipp Hancke [email protected] wrote:

wondering if just window.chrome is a good way to identify chrome. This would cover chrome, opera and brave at least.

@foolip https://github.com/foolip do you know if there is any description of window.chrome?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/webrtc/adapter/issues/764#issuecomment-380426029, or mute the thread https://github.com/notifications/unsubscribe-auth/ACRSrziZtI8yWTnzR_QuefzUTBeFSbk2ks5tne-NgaJpZM4RzyuY .

zaxy78 avatar Apr 11 '18 12:04 zaxy78

@zaxy78 good point, it does. However we can tell Edge apart since it has RTCIceGatherer from ORTC

fippo avatar Apr 11 '18 12:04 fippo

I know there are Chromium-based browsers which don't have window.chrome, and some that do, so I'd say that's worse that UA sniffing :)

foolip avatar Apr 11 '18 16:04 foolip

https://bugs.chromium.org/p/chromium/issues/detail?id=946516 -- this breaks on http because Chrome 74 removed webkitGetUserMedia there.

fippo avatar Mar 27 '19 16:03 fippo

https://web.dev/migrate-to-ua-ch/ might solve the problem. We just need the major version anyway.

fippo avatar May 22 '22 06:05 fippo

@beaufortfrancois can you find folks with an opinion on the approach in https://github.com/webrtcHacks/adapter/pull/1103 ?

fippo avatar Mar 06 '24 16:03 fippo

@yoavweiss and @miketaylr may have opinions on this issue

beaufortfrancois avatar Mar 07 '24 08:03 beaufortfrancois

I don't have a ton of context (e.g. why do we need to detect Chromium here?), but superficially, the approach seems reasonable.

yoavweiss avatar Mar 07 '24 08:03 yoavweiss

Some WebRTC features are only available in certain versions (and there are bugs so you often need version detection anyway) so there is a ton of application code that looks "what browser am I in and what workaround is required here. Proper feature detection is better but a lot of these things do not have any exposed API surface.

Shouldn't be necessary in 2024 but ... it is. Let me see if I can revive #1103...

fippo avatar Mar 07 '24 13:03 fippo

See also https://github.com/whatwg/compat/issues/266

miketaylr avatar Mar 08 '24 15:03 miketaylr