Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyfill returns misleading CBCS #62

Closed
baseballbrad3 opened this issue Sep 7, 2022 · 6 comments · Fixed by #63 or #65
Closed

Polyfill returns misleading CBCS #62

baseballbrad3 opened this issue Sep 7, 2022 · 6 comments · Fixed by #63 or #65
Assignees
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P1 Big impact or workaround impractical; resolve before feature release type: bug Something isn't working correctly

Comments

@baseballbrad3
Copy link

Have you read the FAQ and checked for duplicate open issues?
Yes

What version of Shaka Player are you using?
4.2.1

Can you reproduce the issue with our latest release version?
Yes

Can you reproduce the issue with the latest code from main?
Yes, via https://nightly-dot-shaka-player-demo.appspot.com/demo/

Are you using the demo app or your own custom app?
Reproducible in both

If custom app, can you reproduce the issue using our demo app?
Yes

What browser and OS are you using?
Windows 10 - Firefox 104.0.2
macOS 10.15.7 - Firefox 104.0.2

For embedded devices (smart TVs, etc.), what model and firmware version are you using?
N/A

What are the manifest and license server URIs?
N/A

What configuration are you using? What is the output of player.getConfiguration()?
N/A

What did you do?
I probed Firefox for support of Widevine CBCS after applying the Shaka Polyfills (shaka.polyfill.installAll()). The behavior is the same if in a code file or in the dev tools console.

const config = [
  {
    label: 'cbcs support',
    audioCapabilities: [
      {
        contentType: `audio/mp4; codecs="mp4a.40.2"`,
        encryptionScheme: 'cbcs',
        robustness: 'SW_SECURE_CRYPTO',
      },
    ],
    videoCapabilities: [
      {
        contentType: `video/mp4;codecs="avc1.42E01E"`,
        encryptionScheme: 'cbcs',
        robustness: 'SW_SECURE_CRYPTO',
      },
    ],
  },
];

await navigator.requestMediaKeySystemAccess('com.widevine.alpha', config);

What did you expect to happen?
I expected Firefox to report that this config object was a supported configuration. Running the same code block in Firefox's dev tools console on a page without the polyfills applied indicates that it is a supported configuration. It's worth noting that Chrome/Edge do work after the polyfill.

What actually happened?
An exception is thrown indicating that it is not a supported configuration:
Uncaught (in promise) NotSupportedError: Unsupported keySystem or supportedConfigurations.

I made a Stack Blitz showing that when ran with Firefox, the native navigator.requestMediaKeySystemAccess indicates support, while after applying the polyfill, it is not supported.
https://shaka-player-eme-polyfill-cbcs-issue.stackblitz.io/
https://stackblitz.com/edit/shaka-player-eme-polyfill-cbcs-issue?file=index.js&view=editor
(Note that their editor's preview iframe doesn't provide permissions for encrypted-media, so it must be opened in a new tab)

We're undergoing an effort to remove any OS version detection in favor of feature detection as the User Agent is becoming unreliable. We're detecting CBCS support with similar code to the example in the Stack Blitz, which is working with the exception of Firefox. The current workaround is to get a reference to the native navigator.requestMediaKeySystemAccess prior to the polyfill being applied, calling that reference, then falling back to the post-polyfilled navigator.requestMediaKeySystemAccess if the native version doesn't indicate success.

@baseballbrad3 baseballbrad3 added the type: bug Something isn't working correctly label Sep 7, 2022
@avelad avelad added the browser: Firefox Issues affecting Firefox or Gecko derivatives label Oct 31, 2022
@avelad avelad added the priority: P1 Big impact or workaround impractical; resolve before feature release label Dec 4, 2023
@avelad avelad changed the title Polyfill returns misleading CBCS support in Firefox Polyfill returns misleading CBCS Apr 26, 2024
@avelad avelad removed the browser: Firefox Issues affecting Firefox or Gecko derivatives label Apr 26, 2024
@joeyparrish
Copy link
Member

I'm using Firefox 125 on Ubuntu, and I find that when you query encryptionScheme support through EME, it does not recognize the field at all. IIRC, this is what is triggering the polyfill to activate.

Note that DRM decryption support is separate from the ability to query it. The CDM may be able to decrypt CBCS, but the browser may not understand the query or consider the encryptionScheme field.

I'll double-check the status through MCap as well, in case Firefox implemented encryptionScheme support in that API only.

@joeyparrish
Copy link
Member

Open bug for encryptionScheme implementation in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1860910

@joeyparrish
Copy link
Member

CBCS support in Firefox seems to have been added around late 2018.

@joeyparrish
Copy link
Member

I'm migrating this issue to the polyfill repo.

@joeyparrish joeyparrish transferred this issue from shaka-project/shaka-player Apr 29, 2024
@joeyparrish joeyparrish added the browser: Firefox Issues affecting Firefox or Gecko derivatives label Apr 29, 2024
@joeyparrish
Copy link
Member

Firefox 125 doesn't support encryptionScheme checks in EME or in MediaCapabilities. So there is no way to check for this at runtime. The polyfill has to be in play on Firefox.

So the only thing we can do is to have the polyfill check the Firefox version number and return different results based on that.

I expected Firefox to report that this config object was a supported configuration. Running the same code block in Firefox's dev tools console on a page without the polyfills applied indicates that it is a supported configuration. It's worth noting that Chrome/Edge do work after the polyfill.

What you're overlooking by doing that is that on Firefox, we can query a completely fictional encryption scheme and it will still report supported: true. It is ignoring the field completely. You can also tell it is ignored by checking decodingInfo.keySystemAccess.getConfiguration().videoCapabilities[0]. If encryptionScheme isn't there, it wasn't checked.

The polyfill uses this fact (missing encryptionScheme in the results) to know when to activate its own logic to check encryptionScheme against assumptions made for each browser. And since Firefox is the only one that shipped CBCS support for multiple years without a way to query it... the best we can do in the polyfill is check the Firefox version at runtime.

joeyparrish added a commit to joeyparrish/shaka-player that referenced this issue Apr 29, 2024
This will add encryption schemes to the DRM support report generated
by probeSupport() and support.html.

Related to shaka-project/eme-encryption-scheme-polyfill#62, PR shaka-project#6484,
and issue shaka-project#1419.
@avelad
Copy link
Collaborator

avelad commented Apr 30, 2024

The feature can be enabled in Firefox in about:config with media.eme.encrypted-media-encryption-scheme.enabled

avelad added a commit to shaka-project/shaka-player that referenced this issue May 6, 2024
This will add encryption schemes to the DRM support report generated by
probeSupport() and support.html.

Related to shaka-project/eme-encryption-scheme-polyfill#62, PR #6484,
and issue #1419.

---------

Co-authored-by: Álvaro Velad Galván <ladvan91@hotmail.com>
joeyparrish added a commit that referenced this issue May 7, 2024
Fixes #62

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: Firefox Issues affecting Firefox or Gecko derivatives priority: P1 Big impact or workaround impractical; resolve before feature release type: bug Something isn't working correctly
Projects
None yet
3 participants