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(playback-watcher): ignore subtitles #980

Merged
merged 2 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 0 additions & 13 deletions src/playback-watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import window from 'global/window';
import * as Ranges from './ranges';
import logger from './util/logger';
import videojs from 'video.js';

// Set of events that reset the playback-watcher time check logic and clear the timeout
const timerCancelEvents = [
Expand Down Expand Up @@ -219,18 +218,6 @@ export default class PlaybackWatcher {
this.resetSegmentDownloads_(type);
this.tech_.trigger({type: 'usage', name: `vhs-${type}-download-exclusion`});

if (type === 'subtitle') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think by removing this we will still try to blacklist subtitle tracks when we don't have subtitles in the segments. Should we just return early for subtitles tracks, or, in loaderTypes above, remove subtitles?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, we'll still try to exclude it but at least it won't be removed. Yeah, exiting early here when it's of type subtitle sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to return here but not remove the track.

// TODO: Is there anything else that we can do here?
// removing the track and disabling could have accesiblity implications.
const track = loader.track();
const label = track.label || track.language || 'Unknown';

videojs.log.warn(`Text track "${label}" is not working correctly. It will be disabled and excluded.`);
track.mode = 'disabled';
this.tech_.textTracks().removeTrack(track);
return;
}

// TODO: should we exclude audio tracks rather than main tracks
// when type is audio?
mpc.blacklistCurrentPlaylist({
Expand Down
88 changes: 44 additions & 44 deletions test/playback-watcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,64 +933,64 @@ QUnit.module('PlaybackWatcher download detection', {
});

loaderTypes.forEach(function(type) {
QUnit.test(`detects ${type} appends without buffer changes and excludes`, function(assert) {
this.setup();
const loader = this.mpc[`${type}SegmentLoader_`];
const track = {label: 'foobar', mode: 'showing'};
if (type !== 'subtitle') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should just return in here if type === 'subtitle' would keep the changes down. LGTM otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that but it didn't seem to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems strange. It wouldn't execute for other loader types of returning early on subtitles?

QUnit.test(`detects ${type} appends without buffer changes and excludes`, function(assert) {
this.setup();
const loader = this.mpc[`${type}SegmentLoader_`];
const track = {label: 'foobar', mode: 'showing'};

if (type === 'subtitle') {
loader.track = () => track;
sinon.stub(this.player.tech_.textTracks(), 'removeTrack');
}
if (type === 'subtitle') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this past be removed because we return early on subtitles?

loader.track = () => track;
sinon.stub(this.player.tech_.textTracks(), 'removeTrack');
}

this.setBuffered(videojs.createTimeRanges([[0, 30]]));
this.setBuffered(videojs.createTimeRanges([[0, 30]]));

for (let i = 0; i <= EXCLUDE_APPEND_COUNT; i++) {
loader.trigger('appendsdone');
if (i === EXCLUDE_APPEND_COUNT) {
assert.equal(this.playbackWatcher[`${type}StalledDownloads_`], 0, `append #${i} resets stalled downloads to 0`);
} else {
assert.equal(this.playbackWatcher[`${type}StalledDownloads_`], i, `append #${i + 1} ${i} stalled downloads`);
for (let i = 0; i <= EXCLUDE_APPEND_COUNT; i++) {
loader.trigger('appendsdone');
if (i === EXCLUDE_APPEND_COUNT) {
assert.equal(this.playbackWatcher[`${type}StalledDownloads_`], 0, `append #${i} resets stalled downloads to 0`);
} else {
assert.equal(this.playbackWatcher[`${type}StalledDownloads_`], i, `append #${i + 1} ${i} stalled downloads`);
}
}
}

const expectedUsage = {};
const expectedUsage = {};

expectedUsage[`vhs-${type}-download-exclusion`] = 1;
expectedUsage[`vhs-${type}-download-exclusion`] = 1;

if (type !== 'subtitle') {
expectedUsage['vhs-rendition-blacklisted'] = 1;
expectedUsage['hls-rendition-blacklisted'] = 1;
}
if (type !== 'subtitle') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional probably can be removed.

expectedUsage['vhs-rendition-blacklisted'] = 1;
expectedUsage['hls-rendition-blacklisted'] = 1;
}

assert.deepEqual(this.usageEvents, expectedUsage, 'usage as expected');
assert.deepEqual(this.usageEvents, expectedUsage, 'usage as expected');

if (type !== 'subtitle') {
const message = 'Playback cannot continue. No available working or supported playlists.';
if (type !== 'subtitle') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional probably can be removed, and the else as well.

const message = 'Playback cannot continue. No available working or supported playlists.';

assert.equal(this.mpcErrors, 1, 'one mpc error');
assert.equal(this.mpc.error, message, 'mpc error set');
assert.equal(this.player.error().message, message, 'player error set');
assert.equal(this.env.log.error.callCount, 1, 'player error logged');
assert.equal(this.env.log.error.args[0][1], message, 'error message as expected');
assert.equal(this.mpcErrors, 1, 'one mpc error');
assert.equal(this.mpc.error, message, 'mpc error set');
assert.equal(this.player.error().message, message, 'player error set');
assert.equal(this.env.log.error.callCount, 1, 'player error logged');
assert.equal(this.env.log.error.args[0][1], message, 'error message as expected');

this.env.log.error.resetHistory();
} else {
const message = 'Text track "foobar" is not working correctly. It will be disabled and excluded.';
this.env.log.error.resetHistory();
} else {
const message = 'Text track "foobar" is not working correctly. It will be disabled and excluded.';

assert.equal(this.mpcErrors, 0, 'no mpc error set');
assert.notOk(this.player.error(), 'no player error set');
assert.equal(this.player.textTracks().removeTrack.callCount, 1, 'text track remove called');
assert.equal(this.player.textTracks().removeTrack.args[0][0], track, 'text track remove called with expected');
assert.equal(track.mode, 'disabled', 'mode set to disabled now');
assert.equal(this.env.log.warn.callCount, 1, 'warning logged');
assert.equal(this.env.log.warn.args[0][0], message, 'warning message as expected');
assert.equal(this.mpcErrors, 0, 'no mpc error set');
assert.notOk(this.player.error(), 'no player error set');
assert.equal(this.player.textTracks().removeTrack.callCount, 1, 'text track remove called');
assert.equal(this.player.textTracks().removeTrack.args[0][0], track, 'text track remove called with expected');
assert.equal(track.mode, 'disabled', 'mode set to disabled now');
assert.equal(this.env.log.warn.callCount, 1, 'warning logged');
assert.equal(this.env.log.warn.args[0][0], message, 'warning message as expected');

this.env.log.warn.resetHistory();
}
});
this.env.log.warn.resetHistory();
}
});

if (type !== 'subtitle') {
QUnit.test(`detects ${type} appends without buffer changes and excludes many playlists`, function(assert) {
this.setup({src: 'multipleAudioGroupsCombinedMain.m3u8', type: 'application/vnd.apple.mpegurl'});

Expand Down