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

[WIP] Call generateRequest BEFORE pushing any segment with PlayReady #1486

Closed
wants to merge 1 commit into from

Conversation

peaBerberian
Copy link
Collaborator

@peaBerberian peaBerberian commented Jul 23, 2024

NOTE: This update is under tests by the partners that reported the issue, we aren't sure if it fixes the issue for them for now. I mainly opened this PR to add visibility to what that change could do and trigger discussions between RxPlayer developers.


Another day, another PlayReady-specific issue :/

A partner signalled to us that they weren't able to play a mix of unencrypted and encrypted content on any PlayReady devices.

After investigation, it seems that calling generateRequest for the first time after clear segments are already present on a MSE SourceBuffer associated to the MediaSource linked to the corresponding media element immediately triggered an HTML5 MEDIA_ERR_DECODE error.

We tried A LOT of work-arounds:

  • patching clear segments with a tenc box with a 0x0 key id to incite the CDM to understand that encrypted contents may be pushed in the future

  • Rewriting the pssh sent through the EME generateRequest API so that it is barebone to limit weird PlayReady edge cases.

  • Replacing those stream clear segments' with those in our demo page, just to check that the clear segments were not at fault here

  • Waiting more time between the association of a MediaKeys to the media element and pushing the first segments.

None of those actions had an effect.

However, what had an effect, was to call the generateRequest API BEFORE buffering any segment yet AFTER attaching the MediaKeys (and perhaps MediaSource) to the media element.

So this PR does just that, communicating dummy initialization data for a session that will be closed directly after.

Note that we already do a fake generateRequest on Edge Chromium with Playready since #1434, yet this test was not sufficient, seemingly because it is performed BEFORE MediaKeys attachment.

Note that this PR fixes the clear -> encrypted issues our partner were having, but we're unsure yet of if it fixes the encrypted -> clear issues (and I have good reasons to think it does not).

So, uh, yeah, PlayReady seems to keep being hard-at-work giving us challenges and head-scratchers.

@peaBerberian peaBerberian added bug This is an RxPlayer issue (unexpected result when comparing to the API) DRM Relative to DRM (EncryptedMediaExtensions) work-in-progress This Pull Request or issue is not finished yet Compatibility Relative to the RxPlayer's compatibility with various devices and environments labels Jul 23, 2024
@peaBerberian peaBerberian force-pushed the fix/genreq-before-buffering branch 3 times, most recently from 8fad022 to b2a68bf Compare July 23, 2024 15:32
shouldCallGenerateRequestBeforeBufferingMedia(mediaKeySystemAccess.keySystem)
) {
try {
await performFakeGenerateRequest(mediaKeys);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: maybe this does not need to be done if MediaKeySessions have already been created (and their generateRequest method called)?

To check, it could save us some time when playing multiple contents

@peaBerberian peaBerberian force-pushed the fix/genreq-before-buffering branch from b2a68bf to d5ba127 Compare July 23, 2024 15:33
Another day, another PlayReady-specific issue :/

A partner signalled to us that they weren't able to play a mix of
unencrypted and encrypted content on any PlayReady devices.

After investigation, it seems that calling `generateRequest` for the
first time after clear segments are already present on a MSE
`SourceBuffer` associated to the MediaSource linked to the
corresponding media element immediately triggered an HTML5
`MEDIA_ERR_DECODE` error.

We tried A LOT of work-arounds:

  - patching clear segments with a `tenc` box with a `0x0` key id to
    incite the CDM to understand that encrypted contents may be pushed
    in the future

  - Rewriting the pssh sent through the EME `generateRequest` API so
    that it is barebone to limit weird PlayReady edge cases.

  - Replacing those stream clear segments' with those in our demo page,
    just to check that the clear segments were not at fault here

  - Waiting more time between the association of a MediaKeys to the
    media element and pushing the first segments.

None of those actions had an effect.

However, what had an effect, was to call the `generateRequest` API
BEFORE buffering any segment yet AFTER attaching the MediaKeys (and
perhaps MediaSource) to the media element.

So this commit does just that, communicating dummy initialization data
for a session that will be closed directly after.

Note that we already do a fake `generateRequest` on Edge Chromium with
Playready since #1434, yet this test was not sufficient, seemingly
because it is performed BEFORE MediaKeys attachment.

Note that this commit fixes the clear -> encrypted issues our partner
were having, but we're unsure yet of if it fixes the encrypted -> clear
issues (and I have good reasons to think it does not).

So, uh, yeah, PlayReady seems to keep being hard-at-work giving us
challenges and head-scratchers.
@peaBerberian peaBerberian force-pushed the fix/genreq-before-buffering branch from d5ba127 to 351ec6d Compare July 23, 2024 15:35
@peaBerberian
Copy link
Collaborator Author

Turns out this doesn't really fix the issue, it leads to an infinite rebuffering when encrypted data is actually encountered (see #1403). Closing it

@peaBerberian peaBerberian added this to the 4.2.0 milestone Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is an RxPlayer issue (unexpected result when comparing to the API) Compatibility Relative to the RxPlayer's compatibility with various devices and environments DRM Relative to DRM (EncryptedMediaExtensions) work-in-progress This Pull Request or issue is not finished yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant