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

feat: Raise fatal error on linear manifest request update failure #5138

Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ shaka.extern.MssManifestConfiguration;
* segmentRelativeVttTiming: boolean,
* dash: shaka.extern.DashManifestConfiguration,
* hls: shaka.extern.HlsManifestConfiguration,
* mss: shaka.extern.MssManifestConfiguration
* mss: shaka.extern.MssManifestConfiguration,
* raiseFatalErrorOnManifestUpdateRequestFailure: boolean
* }}
*
* @property {shaka.extern.RetryParameters} retryParameters
Expand Down Expand Up @@ -975,6 +976,9 @@ shaka.extern.MssManifestConfiguration;
* Advanced parameters used by the HLS manifest parser.
* @property {shaka.extern.MssManifestConfiguration} mss
* Advanced parameters used by the MSS manifest parser.
* @property {boolean} raiseFatalErrorOnManifestUpdateRequestFailure
* If true, manifest update request failures will cause a fatal errror.
* Defaults to <code>false</code> if not provided.
*
* @exportDoc
*/
Expand Down
4 changes: 4 additions & 0 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,10 @@ shaka.dash.DashParser = class {

// Try updating again, but ensure we haven't been destroyed.
if (this.playerInterface_) {
if (this.config_.raiseFatalErrorOnManifestUpdateRequestFailure) {
this.playerInterface_.onError(error);
return;
}
// We will retry updating, so override the severity of the error.
error.severity = shaka.util.Error.Severity.RECOVERABLE;
this.playerInterface_.onError(error);
Expand Down
5 changes: 5 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3327,6 +3327,11 @@ shaka.hls.HlsParser = class {
goog.asserts.assert(error instanceof shaka.util.Error,
'Should only receive a Shaka error');

if (this.config_.raiseFatalErrorOnManifestUpdateRequestFailure) {
this.playerInterface_.onError(error);
return;
}

// We will retry updating, so override the severity of the error.
error.severity = shaka.util.Error.Severity.RECOVERABLE;
this.playerInterface_.onError(error);
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ shaka.util.PlayerConfiguration = class {
disableThumbnails: false,
defaultPresentationDelay: 0,
segmentRelativeVttTiming: false,
raiseFatalErrorOnManifestUpdateRequestFailure: false,
dash: {
clockSyncUri: '',
ignoreDrmInfo: false,
Expand Down
35 changes: 35 additions & 0 deletions test/dash/dash_parser_live_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ describe('DashParser Live', () => {
const onError = jasmine.createSpy('onError');
playerInterface.onError = Util.spyFunc(onError);

const updateTick = updateTickSpy();

fakeNetEngine.setResponseText('dummy://foo', manifestText);
await parser.start('dummy://foo', playerInterface);

Expand All @@ -603,6 +605,39 @@ describe('DashParser Live', () => {

await updateManifest();
expect(onError).toHaveBeenCalledTimes(1);
expect(updateTick).toHaveBeenCalledTimes(2);
});

it('fatal error on manifest update request failure when ' +
'raiseFatalErrorOnManifestUpdateRequestFailure is true', async () => {
const manifestConfig =
shaka.util.PlayerConfiguration.createDefault().manifest;
manifestConfig.raiseFatalErrorOnManifestUpdateRequestFailure = true;
parser.configure(manifestConfig);

const updateTick = updateTickSpy();

const lines = [
'<SegmentTemplate startNumber="1" media="s$Number$.mp4" duration="2"/>',
];
const manifestText = makeSimpleLiveManifestText(lines, updateTime);
/** @type {!jasmine.Spy} */
const onError = jasmine.createSpy('onError');
playerInterface.onError = Util.spyFunc(onError);

fakeNetEngine.setResponseText('dummy://foo', manifestText);
await parser.start('dummy://foo', playerInterface);

const error = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.BAD_HTTP_STATUS);
const operation = shaka.util.AbortableOperation.failed(error);
fakeNetEngine.request.and.returnValue(operation);

await updateManifest();
expect(onError).toHaveBeenCalledWith(error);
expect(updateTick).toHaveBeenCalledTimes(1);
});

it('uses @minimumUpdatePeriod', async () => {
Expand Down
3 changes: 2 additions & 1 deletion test/demo/demo_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ describe('Demo', () => {
.add('manifest.hls.mediaPlaylistFullMimeType')
.add('manifest.mss.keySystemsBySystemId')
.add('drm.keySystemsMapping')
.add('streaming.parsePrftBox');
.add('streaming.parsePrftBox')
.add('manifest.raiseFatalErrorOnManifestUpdateRequestFailure');

/**
* @param {!Object} section
Expand Down
37 changes: 37 additions & 0 deletions test/hls/hls_live_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ describe('HlsParser live', () => {
parser.stop();
});

/**
* Gets a spy on the function that sets the update period.
* @return {!jasmine.Spy}
* @suppress {accessControls}
*/
function updateTickSpy() {
return spyOn(parser.updatePlaylistTimer_, 'tickAfter');
}

/**
* Trigger a manifest update.
* @suppress {accessControls}
Expand Down Expand Up @@ -332,6 +341,34 @@ describe('HlsParser live', () => {
expect(notifySegmentsSpy).toHaveBeenCalled();
});

it('fatal error on manifest update request failure when ' +
'raiseFatalErrorOnManifestUpdateRequestFailure is true', async () => {
const manifestConfig =
shaka.util.PlayerConfiguration.createDefault().manifest;
manifestConfig.raiseFatalErrorOnManifestUpdateRequestFailure = true;
parser.configure(manifestConfig);

const updateTick = updateTickSpy();

await testInitialManifest(master, media);
expect(updateTick).toHaveBeenCalledTimes(1);

/** @type {!jasmine.Spy} */
const onError = jasmine.createSpy('onError');
playerInterface.onError = shaka.test.Util.spyFunc(onError);

const error = new shaka.util.Error(
shaka.util.Error.Severity.CRITICAL,
shaka.util.Error.Category.NETWORK,
shaka.util.Error.Code.BAD_HTTP_STATUS);
const operation = shaka.util.AbortableOperation.failed(error);
fakeNetEngine.request.and.returnValue(operation);

await delayForUpdatePeriod();
expect(onError).toHaveBeenCalledWith(error);
expect(updateTick).toHaveBeenCalledTimes(1);
});

it('converts to VOD only after all playlists end', async () => {
const master = [
'#EXTM3U\n',
Expand Down