Video hosted by Apple at devstreaming-cdn.apple.com

Configure player

Close

WWDC Index does not host video files

If you have access to video files, you can configure a URL pattern to be used in a video player.

URL pattern

preview

Use any of these variables in your URL pattern, the pattern is stored in your browsers' local storage.

$id
ID of session: wwdc2020-10231
$eventId
ID of event: wwdc2020
$eventContentId
ID of session without event part: 10231
$eventShortId
Shortened ID of event: wwdc20
$year
Year of session: 2020
$extension
Extension of original filename: mp4
$filenameAlmostEvery
Filename from "(Almost) Every..." gist: [2020] [Session 10231] Reduce la...

WWDC20 • Session 10231

Reduce latency with HLS Blocking Playlist Reload

Media • iOS, macOS, tvOS, watchOS • 8:40

Blocking Playlist Reload is a required component of Low-Latency HLS that improves segment discovery time in live streams and addresses the common problem of stale playlists when delivering through an HTTP cache. Learn how to use Blocking Playlist Reload to reduce streaming latency and improve CDN performance for both low-latency and regular live HLS streams.

Speaker: Roger Pantos

Open in Apple Developer site

Downloads from Apple

HD Video (67 MB)
SD Video (21.6 MB)

Transcript

Hello, and welcome to WWDC. Hello and welcome to this year's WWDC. My name is Roger Pantos, and I'm going to tell you about HLS Blocking Playlist Reload. To start with, what is Blocking Playlist Reload? Well, a fundamental aspect of HLS is that clients are discovering new segments constantly by reloading the Playlist. The original approach was just to reload the same Playlist URL every Target Duration. Now, that's nice and simple, but it doesn't work well with Low-Latency. Because if a client just misses a Playlist update, it'll take another Target Duration before it finally notices it.

And so, for Low-Latency HLS we introduced the notion of Delivery Directives, which are a way for the client to ask the server to perform some kind of service for it by adding query parameters to its get requests. For Blocking Playlist Reload, clients can use a Delivery Directive to tell the server, hold on to this Playlist request until the Playlist you see contains a segment that I haven't seen yet.

Once that Playlist updates with that segment, the server will unblock and send it to the client. So let's take a look at how that works in detail. First of all, Blocking Playlist Reloads are optional, so the server needs to indicate that it supports them. And it does that by adding a CAN-BLOCK-RELOAD attribute to its server control tag. Next, a client will load a Playlist for the first time. It doesn't supply any query parameters because at this point it just wants whatever's current on the server.

As soon as it gets the Playlist, it will immediately turn around and issue a reload request. And now it will use the HLS_msn Delivery Directive to specify the first new segment that it hasn't seen yet. And if it's a Low-Latency Playlist, then it will also specify the next Partial Segment that it expects to see.

The server will then hold on to that request until it has a Playlist that's new enough. Now let's see how that looks graphically. Here we have an HLS client to the left and a server to the right. The client asks for a Playlist that contains Partial Segment 2, for example.

The server doesn't have Partial Segment 2 yet, so it blocks. Eventually Partial Segment 2 will appear and will get added to the Playlist. Now the server can unblock the client request and send it the updated Playlist as the response. Let's take a look at an actual example. We'll start with a regular Playlist, not a Low-Latency one.

Here is a regular live HLS Playlist. The first thing to notice is that the server is advertising that it supports Blocking Playlist Reload in its server control tag. Next, the Media Sequence Number is 19, and that refers to the first segment in the Playlist, which here is Segment A.

Now, if you count four segments down, all the way to the bottom to Segment E, you'll see that it has a Media Sequence Number of 23, and that means that the next time a Playlist is updated with a new segment, that new segment will be Media Sequence Number 24. So to ask for that update, the client will use the HLS_msn=24 Delivery Directive.

When it receives this request, the server will block until the Playlist is updated, and then it will return the newer version of the Playlist. And at the end, it now contains Segment F, also known as Media Sequence Number 24. So that's the flow of Blocking Playlist Reload for regular segments. Now let's see what happens for Low-Latency.

In this example, we'll see how the client asks for the next Playlist when it contains partial segments as well. So, here we have a live Low-Latency Playlist. You can see that the segments have a Target Duration of six seconds, while the partial segments have a part Target Duration of two seconds. At the end of the Playlist are the first two parts of Segment 7-- part zero and part 1.

Given that the last thing in this Playlist right now is Media Sequence 7 part 1, to get the next Playlist the client will need to ask for Media Sequence 7 part 2. And so that request looks like this: The server will hold on to it until the Playlist updates again and then send back this response.

And now we can see that there's a new partial segment which has Media Sequence Number 7 part 2. Now, you may be wondering, if the client is always asking for the next part of the current media sequence number, what happens at the end of the segment? Well, let's go back to our earlier Playlist.

Here the next Playlist request will be for Segment 7 part 3. Now, the server will translate any request for a part that goes beyond the end of the parent segment into a request for part zero of the segment that follows it. So in this case the server will block until it returns this Playlist, where it now contains part zero of segment 8 at the end. There are a few other exceptional cases to know about for Blocking Playlist Reload.

First, the Media Sequence Number and part Delivery Directives only apply for live Playlists. That means they're ignored if a Playlist has an ENDLIST tag. Next, if a client asks for a particular Playlist update and the server already has it, it returns the latest Playlist right away. That's also true even if the Playlist is newer than what the client has asked for, if it's advanced ahead by a couple of Partial Segments.

And in fact, to take it to the greatest extreme, if the segment the client asks for has already rolled out of the Playlist completely, the server will still unblock immediately and return the current Playlist. The rule is that the origin always returns to the current version of the Playlist as long as it's new enough. Finally, if the server has to wait too long for the Playlist to update-- if it has to wait more than three Target Durations-- it will return an error. Now, that should only happen if there's a serious problem with the back-end production.

Another interesting area to talk about is how Blocking Playlist Reload interacts with CDNs and other HTTP caches. The good news here is that Blocking Playlist Reload actually works a lot better with caches even than traditional live HLS. A big reason for that is having a unique URL for each individual Playlist update allows each request to be cached independently. So the update request and response for MSN 23, for example, can live in the same cache alongside the request and response for MSN 24. Now, this has a couple of useful consequences.

First, a new request will effectively bust through the cache because it will present a combination of query parameters that the cache has never seen before, so the cache knows to send the request right along to the origin. Second, each response has a longer useful lifetime in the cache because it doesn't have to compete with itself. You no longer have to expire every Playlist response in a half-Target Duration, the way you do with regular live HLS Playlists. And in fact, we recommend a lifetime of six Target Durations for successful Playlist responses.

The other thing worth saying is that with Blocking Playlist Reload and other Delivery Directives, you have to configure your CDN to coalesce duplicate edge requests into a single request to the origin, because when you have an active origin you'll want to do everything you can to help reduce its load. So, to summarize Blocking Playlist Reload, it's a new mechanism in HLS that allows clients to discover new segments as soon as they become available on the server. Clients request them by using the msn and part Delivery Directives.

Blocking Playlist Reload works better with CDNs, both in a positive sense of enabling more caching and also in the negative sense of explicitly busting that cache for new requests. This helps out with regular live HLS streams and it's required for Low-Latency streams. We encourage you to adopt Blocking Playlist Reload to improve the delivery of HLS to your users. Thank you very much.