Skip to content

Commit

Permalink
fix(DASH): fix memory leak with SegmentTimeline (#3039)
Browse files Browse the repository at this point in the history
We found the issue within our app with the latest Chromecast CAF receiver update (November 22, 2020) that use Shaka 3.0.x. With our live stream containing 90 minutes of buffer, we notice high level of buffering issue with our customer.

It seems that the createUris callback was holding onto a parsing context in each reference.

Closes #3038
  • Loading branch information
Dany L'Hébreux committed Dec 10, 2020
1 parent 26fac12 commit ed953bf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Bonnier Broadcasting <*@bonnierbroadcasting.com>
Bryan Huh <bhh1988@gmail.com>
Code It <*@code-it.fr>
Damien Deis <developer.deis@gmail.com>
Dany L'Hébreux <danylhebreux@gmail.com>
Esteban Dosztal <edosztal@gmail.com>
Fadomire <fadomire@gmail.com>
Google Inc. <*@google.com>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Chad Assareh <assareh@google.com>
Chris Fillmore <fillmore.chris@gmail.com>
Costel Madalin Grecu <madalin.grecu@adswizz.com>
Damien Deis <developer.deis@gmail.com>
Dany L'Hébreux <danylhebreux@gmail.com>
Donato Borrello <donato@jwplayer.com>
Duc Pham <duc.pham@edgeware.tv>
Esteban Dosztal <edosztal@gmail.com>
Expand Down
14 changes: 11 additions & 3 deletions lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,24 @@ shaka.dash.SegmentTemplate = class {
info.unscaledPresentationTimeOffset;
const repId = context.representation.id;
const bandwidth = context.bandwidth || null;
const mediaTemplate = info.mediaTemplate;
const baseUris = context.representation.baseUris;

// This callback must not capture any non-local
// variables, such as info, context, etc. Make
// sure any values you reference here have
// been assigned to local variables within the
// loop, or else we will end up with a leak.
const createUris =
() => {
goog.asserts.assert(
info.mediaTemplate,
mediaTemplate,
'There should be a media template with a timeline');
const mediaUri = MpdUtils.fillUriTemplate(
info.mediaTemplate, repId,
mediaTemplate, repId,
segmentReplacement, bandwidth || null, timeReplacement);
return ManifestParserUtils
.resolveUris(context.representation.baseUris, [mediaUri])
.resolveUris(baseUris, [mediaUri])
.map((g) => {
return g.toString();
});
Expand Down

0 comments on commit ed953bf

Please sign in to comment.