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

fix: DrmEngine exception thrown when using FairPlay #4971

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

martinstark
Copy link
Contributor

@martinstark martinstark commented Feb 6, 2023

Closes #4902

This is not intended to be a complete fix for the issue, I do not understand the effect this new ternary on the shaka player as a whole. I have not found the root cause for this.currentDrmInfo_ being undefined when accessed. It does, however, look like it has previously been acceptable for this property to be undefined. I opened this PR more as a point of discussion around the issue at hand.

During the work to add Fairplay support in 2022, accessing this.currentDrmInfo_ was added on line 483. This line does not accept that this.currentDrmInfo_ can be undefined. A few lines below this, this.createOrLoad() is called, which does accept that this.currentDrmInfo_ can be undefined. The latter piece of code was last modified in 2019.

const manifestInitData = this.currentDrmInfo_.initData.find(
(initDataOverride) => initDataOverride.initData.length > 0);
/**
* We can attach media keys before the playback actually begins when:
* - If we are not using FairPlay Modern EME
* - Some initData already has been generated (through the manifest)
* - In case of an offline session
*/
if (manifestInitData ||
this.currentDrmInfo_.keySystem !== 'com.apple.fps' ||
this.offlineSessionIds_.length) {
await this.attachMediaKeys_();
}
this.createOrLoad();

createOrLoad() {
// Create temp sessions.
const initDatas =
(this.currentDrmInfo_ ? this.currentDrmInfo_.initData : []) || [];

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2023

Incremental code coverage: 100.00%

@avelad avelad added type: bug Something isn't working correctly priority: P1 Big impact or workaround impractical; resolve before feature release labels Feb 6, 2023
@avelad avelad added this to the v4.4 milestone Feb 6, 2023
@joeyparrish joeyparrish changed the title fix: null is not an object (evaluating 'n.g.initData') fix: DrmEngine exception thrown when using FairPlay Feb 6, 2023
@joeyparrish joeyparrish merged commit eebf18c into shaka-project:main Feb 6, 2023
joeyparrish pushed a commit that referenced this pull request Feb 9, 2023
Closes #4902

This is not intended to be a complete fix for the issue, I do not
understand the effect this new ternary on the shaka player as a whole. I
have not found the root cause for `this.currentDrmInfo_` being
`undefined` when accessed. It does, however, look like it has previously
been acceptable for this property to be `undefined`.

During the work to add Fairplay support in 2022, accessing
`this.currentDrmInfo_` was added on line 483. This line **does not**
accept that `this.currentDrmInfo_` can be undefined. A few lines below
this, `this.createOrLoad()` is called, which **does** accept that
`this.currentDrmInfo_` can be `undefined`. The latter piece of code was
last modified in 2019.

https://github.com/shaka-project/shaka-player/blob/c471d23bc25db11dda85a18870ebd3fe37971848/lib/media/drm_engine.js#L483-L498

https://github.com/shaka-project/shaka-player/blob/c471d23bc25db11dda85a18870ebd3fe37971848/lib/media/drm_engine.js#L626-L629
joeyparrish pushed a commit that referenced this pull request Feb 9, 2023
Closes #4902

This is not intended to be a complete fix for the issue, I do not
understand the effect this new ternary on the shaka player as a whole. I
have not found the root cause for `this.currentDrmInfo_` being
`undefined` when accessed. It does, however, look like it has previously
been acceptable for this property to be `undefined`.

During the work to add Fairplay support in 2022, accessing
`this.currentDrmInfo_` was added on line 483. This line **does not**
accept that `this.currentDrmInfo_` can be undefined. A few lines below
this, `this.createOrLoad()` is called, which **does** accept that
`this.currentDrmInfo_` can be `undefined`. The latter piece of code was
last modified in 2019.

https://github.com/shaka-project/shaka-player/blob/c471d23bc25db11dda85a18870ebd3fe37971848/lib/media/drm_engine.js#L483-L498

https://github.com/shaka-project/shaka-player/blob/c471d23bc25db11dda85a18870ebd3fe37971848/lib/media/drm_engine.js#L626-L629
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Safari Fairplay: null is not an object (evaluating 'n.g.initData')
3 participants