Skip to content

Commit

Permalink
Remove console.assert statements
Browse files Browse the repository at this point in the history
Resolves #5218
Closes #5221
  • Loading branch information
robwalch committed Feb 18, 2023
1 parent 509fdab commit 7045c14
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 36 deletions.
13 changes: 8 additions & 5 deletions src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,15 @@ class AudioStreamController
}

const track = levels[trackId] as Level;
console.assert(track, 'Audio track is defined on fragment load progress');
if (!track) {
this.warn('Audio track is defined on fragment load progress');
return;
}
const details = track.details as LevelDetails;
console.assert(
details,
'Audio track details are defined on fragment load progress'
);
if (!details) {
this.warn('Audio track details are defined on fragment load progress');
return;
}
const audioCodec =
config.defaultAudioCodec || track.audioCodec || 'mp4a.40.2';

Expand Down
6 changes: 1 addition & 5 deletions src/controller/audio-track-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,14 @@ class AudioTrackController extends BasePlaylistController {

private selectInitialTrack(): void {
const audioTracks = this.tracksInGroup;
console.assert(
audioTracks.length,
'Initial audio track should be selected when tracks are known'
);
const trackId =
this.findTrackId(this.currentTrack) | this.findTrackId(null);

if (trackId !== -1) {
this.setAudioTrack(trackId);
} else {
const error = new Error(
`No track found for running audio group-ID: ${this.groupId}`
`No track found for running audio group-ID: ${this.groupId} track count: ${audioTracks.length}`
);
this.warn(error.message);

Expand Down
5 changes: 4 additions & 1 deletion src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,10 @@ export default class BaseStreamController
partial: boolean
) {
const details = level.details as LevelDetails;
console.assert(!!details, 'level.details must be defined');
if (!details) {
this.warn('level.details undefined');
return;
}
const parsed = Object.keys(frag.elementaryStreams).reduce(
(result, type) => {
const info = frag.elementaryStreams[type];
Expand Down
2 changes: 0 additions & 2 deletions src/controller/buffer-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,6 @@ export default class BufferController implements ComponentAPI {
logger.log(
`[buffer-controller]: Removing [${removeStart},${removeEnd}] from the ${type} SourceBuffer`
);
console.assert(!sb.updating, `${type} sourceBuffer must not be updating`);
sb.remove(removeStart, removeEnd);
} else {
// Cycle the queue
Expand All @@ -899,7 +898,6 @@ export default class BufferController implements ComponentAPI {
}

sb.ended = false;
console.assert(!sb.updating, `${type} sourceBuffer must not be updating`);
sb.appendBuffer(data);
}

Expand Down
2 changes: 0 additions & 2 deletions src/controller/eme-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ class EMEController implements ComponentAPI {
keySystem: KeySystems;
mediaKeys: MediaKeys;
}): MediaKeySessionContext {
console.assert(!!mediaKeys, 'mediaKeys is defined');

this.log(
`Creating key-system session "${keySystem}" keyId: ${Hex.hexDump(
decryptdata.keyId! || []
Expand Down
3 changes: 0 additions & 3 deletions src/controller/level-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ function updateFromToPTS(fragFrom: Fragment, fragTo: Fragment) {
duration = fragFrom.start - fragToPTS;
frag = fragTo;
}
// TODO? Drift can go either way, or the playlist could be completely accurate
// console.assert(duration > 0,
// `duration of ${duration} computed for frag ${frag.sn}, level ${frag.level}, there should be some duration drift between playlist and fragment!`);
if (frag.duration !== duration) {
frag.duration = duration;
}
Expand Down
5 changes: 0 additions & 5 deletions src/controller/subtitle-stream-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,6 @@ export class SubtitleStreamController
if (bufferLen > maxBufLen) {
return;
}

console.assert(
trackDetails,
'Subtitle track details are defined on idle subtitle stream controller tick'
);
const fragments = trackDetails.fragments;
const fragLen = fragments.length;
const end = trackDetails.edge;
Expand Down
11 changes: 0 additions & 11 deletions src/remux/mp4-remuxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,6 @@ export default class MP4Remuxer implements Remuxer {
}
}
}

console.assert(
mp4SampleDuration !== null,
'mp4SampleDuration must be computed'
);
// next AVC sample DTS should be equal to last sample DTS + last sample duration (in PES timescale)
mp4SampleDuration =
stretchedLastFrame || !mp4SampleDuration
Expand Down Expand Up @@ -685,12 +680,8 @@ export default class MP4Remuxer implements Remuxer {
nb: outputSamples.length,
dropped: track.dropped,
};

track.samples = [];
track.dropped = 0;

console.assert(mdat.length, 'MDAT length must not be zero');

return data;
}

Expand Down Expand Up @@ -957,8 +948,6 @@ export default class MP4Remuxer implements Remuxer {
};

this.isAudioContiguous = true;

console.assert(mdat.length, 'MDAT length must not be zero');
return audioData;
}

Expand Down
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ const multiConfig = [
},
].map((config) => {
const baseClone = merge({}, baseConfig);
// Strip console.assert statements from production webpack targets
if (config.mode === 'production') {
// Strip console.assert statements from build targets
if (config.mode === 'production' || env.NETLIFY === 'true') {
// eslint-disable-next-line no-restricted-properties
baseClone.module.rules
.find((rule) => rule.loader === 'babel-loader')
Expand Down

0 comments on commit 7045c14

Please sign in to comment.