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

fix(preload): Fix preload load latency logic. #6890

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 1 addition & 10 deletions lib/media/preload_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
/**
* @param {string} assetUri
* @param {?string} mimeType
* @param {number} startTimeOfLoad
* @param {?number} startTime
* @param {*} playerInterface
*/
constructor(assetUri, mimeType, startTimeOfLoad, startTime, playerInterface) {
constructor(assetUri, mimeType, startTime, playerInterface) {
super();

// Making the playerInterface a * and casting it to the right type allows
Expand All @@ -67,9 +66,6 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
/** @private {?shaka.media.AdaptationSetCriteria} */
this.currentAdaptationSetCriteria_ = null;

/** @private {number} */
this.startTimeOfLoad_ = startTimeOfLoad;

/** @private {number} */
this.startTimeOfDrm_ = 0;

Expand Down Expand Up @@ -208,11 +204,6 @@ shaka.media.PreloadManager = class extends shaka.util.FakeEventTarget {
return this.startTime_;
}

/** @return {number} */
getStartTimeOfLoad() {
return this.startTimeOfLoad_;
}

/** @return {number} */
getStartTimeOfDRM() {
return this.startTimeOfDrm_;
Expand Down
13 changes: 4 additions & 9 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1616,8 +1616,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
// asset.
const shouldUseSrcEquals = !preloadManager;

const startTimeOfLoad = preloadManager ?
preloadManager.getStartTimeOfLoad() : (Date.now() / 1000);
const startTimeOfLoad = Date.now() / 1000;

// Stats are for a single playback/load session. Stats must be initialized
// before we allow calls to |updateStateHistory|.
Expand Down Expand Up @@ -1805,12 +1804,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
startTime = null;
}
// We have enough information to make a PreloadManager!
const startTimeOfLoad = Date.now() / 1000;
preloadManager = await this.makePreloadManager_(
this.assetUri_,
startTime,
this.mimeType_,
startTimeOfLoad,
/* allowPrefetch= */ true,
/* disableVideo= */ false,
/* allowMakeAbrManager= */ false);
Expand Down Expand Up @@ -1898,7 +1895,6 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
async preloadInner_(assetUri, startTime, mimeType, standardLoad = false) {
goog.asserts.assert(this.networkingEngine_, 'Should have a net engine!');
goog.asserts.assert(this.config_, 'Config must not be null!');
const startTimeOfLoad = Date.now() / 1000;
if (!mimeType) {
mimeType = await this.guessMimeType_(assetUri);
}
Expand All @@ -1925,7 +1921,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
}
}
let preloadManagerPromise = this.makePreloadManager_(
assetUri, startTime, mimeType || null, startTimeOfLoad,
assetUri, startTime, mimeType || null,
/* allowPrefetch= */ !standardLoad, disableVideo, allowMakeAbrManager);
if (!standardLoad) {
// We only need to track the PreloadManager if it is not part of a
Expand All @@ -1945,14 +1941,13 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
* @param {string} assetUri
* @param {?number} startTime
* @param {?string} mimeType
* @param {number} startTimeOfLoad
* @param {boolean=} allowPrefetch
* @param {boolean=} disableVideo
* @param {boolean=} allowMakeAbrManager
* @return {!Promise.<!shaka.media.PreloadManager>}
* @private
*/
async makePreloadManager_(assetUri, startTime, mimeType, startTimeOfLoad,
async makePreloadManager_(assetUri, startTime, mimeType,
allowPrefetch = true, disableVideo = false, allowMakeAbrManager = true) {
goog.asserts.assert(this.networkingEngine_, 'Must have net engine');
/** @type {?shaka.media.PreloadManager} */
Expand Down Expand Up @@ -2173,7 +2168,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
allowMakeAbrManager,
};
preloadManager = new shaka.media.PreloadManager(
assetUri, mimeType, startTimeOfLoad, startTime, playerInterface);
assetUri, mimeType, startTime, playerInterface);
return preloadManager;
}

Expand Down
Loading