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

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

Closed
martinstark opened this issue Jan 16, 2023 · 4 comments · Fixed by #4971
Closed

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

martinstark opened this issue Jan 16, 2023 · 4 comments · Fixed by #4971
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@martinstark
Copy link
Contributor

martinstark commented Jan 16, 2023

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

What version of Shaka Player are you using?
4.2.X

Can you reproduce the issue with our latest release version?
Presumably, need huge volumes of plays to see issue, and cannot take 4.3.X to prod.

Can you reproduce the issue with the latest code from main?
n/a

Are you using the demo app or your own custom app?
custom

If custom app, can you reproduce the issue using our demo app?
n/a

What browser and OS are you using?
Safari, Mac OS

What did you do?
Check our playback error metrics, and noticed unhandled errors thrown inside of Shaka. The errors are rare, in the magnitude of a handful per thousands of plays.

useNativeHlsOnSafari: true

Play Fairplay DRM streams

What did you expect to happen?
Shaka plays the stream, or throws a Shaka Error.

What actually happened?

Shaka crashes with a native ReferenceError null is not an object (evaluating 'n.g.initData')

Note: The issue is probably in our streams, but Shaka probably shouldn't crash with a ReferenceError when it happens.

@martinstark martinstark added the type: bug Something isn't working correctly label Jan 16, 2023
@github-actions github-actions bot added this to the v4.4 milestone Jan 16, 2023
@joeyparrish
Copy link
Member

I don't doubt your data on this, but it's not enough for us to debug the issue. If you have a way to reliably reproduce the issue in the future, please let us know.

@joeyparrish joeyparrish added the status: unable to reproduce Issue could not be reproduced by the team label Jan 19, 2023
@martinstark
Copy link
Contributor Author

martinstark commented Jan 20, 2023

I did some quick digging, and the only instance of \w+\.\w+\.initData[.(/ :;] being accessed without a guard/null check is here:

const manifestInitData = this.currentDrmInfo_.initData.find(

There are two places where currentDrmInfo_ is asynchronously assigned null in the same file, so in theory I think a race condition could occur where a call to attach is queued after currentDrmInfo_ has been set to null? I didn't do that much digging, but line 483 in drm_engine.js stood out.

If you think this could be it, I could work on a PR to mitigate the issue.

@joeyparrish
Copy link
Member

A PR would be welcome, even without solid repro. It would be really great if you could come up with a unit test that reproduces the condition, though. With other components and browser APIs mocked out, it is often feasible to control the timing of things that are normally asynchronous, and to reproduce unlikely race conditions.

@martinstark
Copy link
Contributor Author

This issue just increased by several magnitudes in our error tracking systems, from once or twice every other day to dozens per day. My thought is that it's hiding a deeper DRM/content problem (on our side). I'll be looking more at it and put up a PR for discussion.

joeyparrish pushed a commit that referenced this issue 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`.

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
@avelad avelad removed the status: unable to reproduce Issue could not be reproduced by the team label Feb 6, 2023
joeyparrish pushed a commit that referenced this issue 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 issue 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 Apr 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants