Skip to content

chore(DASH): Add comments to latest DashParser changes #8888

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

Merged
merged 1 commit into from
Jul 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ shaka.dash.DashParser = class {
}
}
}
// Clean the array instead of creating a new one. By doing this we ensure
// that references to the array does not change in callback functions.
this.lastCalculatedBaseUris_.splice(0);
if (!someLocationValid || !this.contentSteeringManager_) {
const uris = uriObjs.map(TXml.getContents);
Expand All @@ -641,13 +643,18 @@ shaka.dash.DashParser = class {
manifestBaseUris, uris));
}

// Here we are creating local variables to avoid direct references to `this`
// in a callback function. By doing this we can ensure that garbage
// collector can clean up `this` object when it is no longer needed.
const contentSteeringManager = this.contentSteeringManager_;
const lastCalculatedBaseUris = this.lastCalculatedBaseUris_;

const getBaseUris = () => {
if (contentSteeringManager && someLocationValid) {
return contentSteeringManager.getLocations('BaseURL');
}
// Return the copy, because caller of this function is not an owner
// of the array.
return lastCalculatedBaseUris.slice();
};

Expand Down Expand Up @@ -2785,6 +2792,9 @@ shaka.dash.DashParser = class {
calculatedBaseUris = uriObjs.map(TXml.getContents);
}

// Here we are creating local variable to avoid direct references to `this`
// in a callback function. By doing this we can ensure that garbage
// collector can clean up `this` object when it is no longer needed.
const contentSteeringManager = this.contentSteeringManager_;

const getFrameUris = () => {
Expand Down
Loading