webrtcHacks / adapter

Shim to insulate apps from spec changes and prefix differences. Latest adapter.js release:
https://webrtcHacks.github.io/adapter/adapter-latest.js
BSD 3-Clause "New" or "Revised" License
3.61k stars 845 forks source link

Firefox will be identified as "Not a supported browser." if mozGetUserMedia is removed #1156

Open jan-ivar opened 4 months ago

jan-ivar commented 4 months ago

https://github.com/webrtcHacks/adapter/issues/764 identified problematic detectBrowser code which prevents browsers from removing non-standard APIs:

    if (navigator.mozGetUserMedia) { // Firefox.
      result.browser = 'firefox';
      result.version = extractVersion(navigator.userAgent,
          /Firefox\/(\d+)\./, 1);
    } else if (navigator.webkitGetUserMedia) {
      // Chrome, Chromium, Webview, Opera.
      // Version matches Chrome/WebRTC version.
      result.browser = 'chrome';
      result.version = extractVersion(navigator.userAgent,
          /Chrom(e|ium)\/(\d+)\./, 2);
    } else if (navigator.mediaDevices &&
        navigator.userAgent.match(/Edge\/(\d+).(\d+)$/)) { // Edge.
      result.browser = 'edge';
      result.version = extractVersion(navigator.userAgent,
          /Edge\/(\d+).(\d+)$/, 2);
    } else if (navigator.mediaDevices &&
        navigator.userAgent.match(/AppleWebKit\/(\d+)\./)) { // Safari.
      result.browser = 'safari';
      result.version = extractVersion(navigator.userAgent,
          /AppleWebKit\/(\d+)\./, 1);
    } else { // Default fallthrough: not supported.
      result.browser = 'Not a supported browser.';
      return result;
    }

E.g. Firefox cannot remove mozGetUserMedia without this returning "Not a supported browser."

The https://github.com/webrtcHacks/adapter/pull/1146 fix to https://github.com/webrtcHacks/adapter/issues/764 is unsatisfactory, relying on an API that is not standards-track to solve this problem only for Chromium.

The core problem, that this function treats browsers without specific non-standard APIs as "Not a supported browser." remains unaddressed.

fippo commented 4 months ago

From what I recall you agreed to this in the context of #151 -- it has been a while though.

jan-ivar commented 4 months ago

Thanks for the link. To clarify, I intimated _"there are no plans to unprefix it."_ on navigator. We have plans to remove it.

fippo commented 4 months ago

If you want to do something more effective than breaking a ton of sites and reducing Firefox WebRTC reach further make that method throw but keep it around?