-
Notifications
You must be signed in to change notification settings - Fork 791
Fix issue 963: error on SourceBuffer creation #1330
Conversation
// However when state is settled on the next tick, | ||
// it seems safe to do so. | ||
createSourceBufferDeferred = | ||
(() => setTimeout(createSourceBuffer, ADD_SOURCE_BUFFER_RETRY_DEFER_MS)); |
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.
running this immediately (zero timeout) doesn't fix the issue.
we have experienced that this type of "delay" allows for a reliable behavior.
that proves this is a pretty "fuzzy" issue in the lower layers imho.
Some tests need to be adapted, since the behavior of SourceUpdater changes concerning creation of SourceBuffer. This fix isn't nice, but it's a workaround for a very real issue (which may also be browser-related). It happens very reproducibly when the media segments are cached, and thus there seems to be a very short period of time after creation of the MediaSource where calls to addSourceBuffer will lead to fatal errors. Hls.js always has a few more ticks between creating MediaSource and adding buffers, which is maybe why we never have observed the issue there. I am actually not exactly sure if the issue also happens when the call to addSourceBuffer happens from the sourceopen event dispatcher. What I am sure is that most of the cases I've seen were when the MediaSource was advertising Hope this may help to understand better what's going on. |
Just another thought: This seems to happen actually only when we need to create several SourceBuffer objects. This leads me to the doubt wether somehow browsers implementations have introduced an intermediate state just after creation of SourceBuffers where we need to wait before the next call to addSourceBuffer. Maybe we need to check |
Thanks for another contribution and all the detailed notes! I agree that the timeout solution, while simplest, is not the most pleasant. If the browsers aren't (or aren't consistently) managing the state when dealing with adding multiple source buffers in quick succession, it may be necessary for us to consider wrapping the media source itself (and/or making changes via videojs-contrib-media-sources) and making the functions async to ensure that we are waiting for each There are a few more details in https://www.w3.org/TR/media-source/#methods , but not complete there either. |
@gesinger Yes totally agree about that. I'd also want the fix/solution to be robust against anything, and for that we need to do it as you describe. |
Is there a status update or work around for this merge? |
I'm also wondering on the status of this. There are certain cases where the vast-vpaid plugin loads a preroll and this error gets thrown. |
This is Issue still alive? I'm trying to solve this... |
Thank you for your PR but we will not be accepting new changes for this repo and will be archived very soon. I would advise you to open your PR against the next iteration of this project at https://github.com/videojs/http-streaming. |
Description
Fixes https://github.com/videojs/videojs-contrib-hls/issues/963, see history/triage there.
Defers creation of SourceBuffer and retries as necessary (see comments in code).
Trying to deal with apparent uncertainty coming from lower layers (MediaSource wrappers or actually browsers implementations).
TODO:
Specific Changes proposed
Please list the specific changes involved in this pull request.
Requirements Checklist