-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
lib/media/media_source_engine.js
Outdated
@@ -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(); ' + |
There was a problem hiding this comment.
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:
- Shaka has a serious bug
- 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().
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…debug => alwaysError.
Incremental code coverage: 94.12% |
…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).
…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).
…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).
…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
Builds on top of @tykus160's observation in #4903 where
MediaSource.readyState
was either in aclosed
orended
state when theMediaSourceEngine.init()
logic is executed.This fix will simply re-open the
MediaSource
if non-open, resulting in fewer scenarios where theMEDIA_SOURCE_OPERATION_THREW
error:shaka-player/lib/media/media_source_engine.js
Lines 648 to 651 in de0f33c
is thrown because of an
InvalidStateError
.