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

Support parallel prefetch of mpeg-dash segments #2809

Closed
wants to merge 1 commit into from

Conversation

sabyasachiroy
Copy link

This diff adds the ability to prefetch and download segments listed in a
mpeg-dash manifest in parallel. Before this diff, the segments would be
downloaded serially.

The exact level of parallelism, or the exact number of segments to be
prefetched is controlled via a configuration "prefetchLimit". When set to
zero, it defaults back to older behaviour. When set to a positive number,
shaka-player would prefetch only that many segments in parallel and
then wait until some of the ongoing downloads finish before issuing more
prefetch requests.

There are some strange observations w.r.t. behaviour with range requests,
pre-flight OPTIONS request and chrome. In many cases every segment
request is preceded by a OPTIONS request. With browser's cache disabled this
often leads to multiple identical OPTIONS request. When cache is enabled,
that causes an undesirable behaviour with chrome. Chrome's cache has a
writer lock and it blocks any subsequent request that has the same URL
as the one being currently downloaded. This, for range requests, often
defeats the purpose of the diff as it leads to serialisation of all range
requests for the same segment (same URL). Thankfully, firefox does not see
this issue.

Tests:
o Ran this version of shaka-player on my local setup and saw
segments getting prefetched in parallel.
o By changing the prefetchLimit, checked that the number of
segments downloads being in flight mimicked the configuration.
o Tested the same on chrome as well as firefox.

This diff adds the ability to download segments listed in a
mpeg-dash manifest in parallel. Before this diff, the segments
would be downloaded serially. This despite knowing the list of
segments to be downloaded apriori. This diff changes that allows
shaka-player to prefetch segment downloads.

The exact level of parallelism, or the exact number of segments
to be prefetched is controlled via a configuration "prefetchLimit".
When set to zero, it defaults back to older behaviour. When set
to a positive number shaka-player would prefetch only those many
segments in parallel and then wait until some of the ongoing
downloads finish before issuing more prefetch requests.

There are some strange observations w.r.t. behaviour with range
requests, pre-flight OPTIONS request and chrome. In many cases
every segment request is preceeding by a OPTIONS request. With
browser's cache disabled this often leads to multiple identical
OPTIONS request. When cache is enabled, that causes an undesirable
behaviour with chrome. Chrome's cache has a writer lock and it blocks
any subsequent request that has the same URL as the one being
currently downloaded. This for range requests often defeats the
purpose of the diff as it leads to serialization of all range
requests for the same segment (same URL). Thankfully, firefox
does not see this issue.

Tests:
o Ran this version of shaka-player on my local setup and saw
  segments getting prefetched in parallel.
o By changing the prefetchLimit, checked that the number of
  segments downloads being in flight mimicked the configuration.
o Tested the same on chrome as well as firefox.
@google-cla
Copy link

google-cla bot commented Aug 19, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@joeyparrish
Copy link
Member

Let us know if you change your mind. We're always happy to discuss enhancements!

@tyrelltle
Copy link
Contributor

tyrelltle commented Nov 10, 2022

Hi @sabyasachiroy
I noticed your PR was closed, have you found alternative solution ?
We are integrating Shaka player in our app, and trying to find a way to avoid rebuffering as much as possible when client network is slow.
We found your PR is helpful and would like to continue this work or learn from you if any other solution has been found.

Thanks !

avelad pushed a commit that referenced this pull request Jan 31, 2023
closes #4658.

This solution is inspired by abandoned PR
#2809, which
implements segment prefetching ahead of current play head.


![image](https://user-images.githubusercontent.com/3315733/205465795-75c605d2-c2e3-4d03-90f5-46a72a7189d2.png)
@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
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants