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: re-open the MediaSource if readyState is not open when the init() method is called. #7783

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

JulianDomingo
Copy link
Contributor

Builds on top of @tykus160's observation in #4903 where MediaSource.readyState was either in a closed or ended state when the MediaSourceEngine.init() logic is executed.

This fix will simply re-open the MediaSource if non-open, resulting in fewer scenarios where the MEDIA_SOURCE_OPERATION_THREW error:

throw new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.MEDIA,
shaka.util.Error.Code.MEDIA_SOURCE_OPERATION_THREW,

is thrown because of an InvalidStateError.

@JulianDomingo JulianDomingo added type: bug Something isn't working correctly priority: P1 Big impact or workaround impractical; resolve before feature release labels Dec 19, 2024
@JulianDomingo JulianDomingo self-assigned this Dec 19, 2024
@@ -551,6 +551,13 @@ shaka.media.MediaSourceEngine = class {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

await this.mediaSourceOpen_;
if (this.ended() || this.closed()) {
shaka.log.debug('Expected MediaSource to be open during init(); ' +
Copy link
Member

Choose a reason for hiding this comment

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

This only occurs if one of these is true:

  1. Shaka has a serious bug
  2. Someone takes the video element out from under Shaka (misusing Shaka)

We should upgrade this to an error and show it in production, too. Please use shaka.log.alwaysError().

Copy link
Member

Choose a reason for hiding this comment

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

Also please fix the linter errors (all line length errors)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@shaka-bot
Copy link
Collaborator

Incremental code coverage: 94.12%

@JulianDomingo JulianDomingo merged commit 6610fa3 into shaka-project:main Dec 20, 2024
16 of 17 checks passed
joeyparrish pushed a commit that referenced this pull request Jan 6, 2025
…init()` method is called. (#7783)

Builds on top of @tykus160's observation in
#4903 where
`MediaSource.readyState` was either in a `closed` or `ended` state when
the `MediaSourceEngine.init()` logic is executed.

This fix will simply re-open the `MediaSource` if non-open, resulting in
fewer scenarios where the `MEDIA_SOURCE_OPERATION_THREW` error:
https://github.com/shaka-project/shaka-player/blob/de0f33c2623b057e80b7cafd53e19fac2f984961/lib/media/media_source_engine.js#L648-L651

is thrown because of an
[`InvalidStateError`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBuffer#exceptions).
joeyparrish pushed a commit that referenced this pull request Jan 6, 2025
…init()` method is called. (#7783)

Builds on top of @tykus160's observation in
#4903 where
`MediaSource.readyState` was either in a `closed` or `ended` state when
the `MediaSourceEngine.init()` logic is executed.

This fix will simply re-open the `MediaSource` if non-open, resulting in
fewer scenarios where the `MEDIA_SOURCE_OPERATION_THREW` error:
https://github.com/shaka-project/shaka-player/blob/de0f33c2623b057e80b7cafd53e19fac2f984961/lib/media/media_source_engine.js#L648-L651

is thrown because of an
[`InvalidStateError`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBuffer#exceptions).
joeyparrish pushed a commit that referenced this pull request Jan 6, 2025
…init()` method is called. (#7783)

Builds on top of @tykus160's observation in
#4903 where
`MediaSource.readyState` was either in a `closed` or `ended` state when
the `MediaSourceEngine.init()` logic is executed.

This fix will simply re-open the `MediaSource` if non-open, resulting in
fewer scenarios where the `MEDIA_SOURCE_OPERATION_THREW` error:
https://github.com/shaka-project/shaka-player/blob/de0f33c2623b057e80b7cafd53e19fac2f984961/lib/media/media_source_engine.js#L648-L651

is thrown because of an
[`InvalidStateError`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBuffer#exceptions).
joeyparrish pushed a commit that referenced this pull request Jan 6, 2025
…init()` method is called. (#7783)

Builds on top of @tykus160's observation in
#4903 where
`MediaSource.readyState` was either in a `closed` or `ended` state when
the `MediaSourceEngine.init()` logic is executed.

This fix will simply re-open the `MediaSource` if non-open, resulting in
fewer scenarios where the `MEDIA_SOURCE_OPERATION_THREW` error:
https://github.com/shaka-project/shaka-player/blob/de0f33c2623b057e80b7cafd53e19fac2f984961/lib/media/media_source_engine.js#L648-L651

is thrown because of an
[`InvalidStateError`](https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBuffer#exceptions).

Release-As: 4.9.2-caf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: P1 Big impact or workaround impractical; resolve before feature release type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants