From 7045c1407c06327015bdaa4a7124bb1fd0decc34 Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Thu, 16 Feb 2023 14:10:20 -0800 Subject: [PATCH] Remove console.assert statements Resolves #5218 Closes #5221 --- src/controller/audio-stream-controller.ts | 13 ++++++++----- src/controller/audio-track-controller.ts | 6 +----- src/controller/base-stream-controller.ts | 5 ++++- src/controller/buffer-controller.ts | 2 -- src/controller/eme-controller.ts | 2 -- src/controller/level-helper.ts | 3 --- src/controller/subtitle-stream-controller.ts | 5 ----- src/remux/mp4-remuxer.ts | 11 ----------- webpack.config.js | 4 ++-- 9 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/controller/audio-stream-controller.ts b/src/controller/audio-stream-controller.ts index 44b274bb7fb..590efc11cb0 100644 --- a/src/controller/audio-stream-controller.ts +++ b/src/controller/audio-stream-controller.ts @@ -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'; diff --git a/src/controller/audio-track-controller.ts b/src/controller/audio-track-controller.ts index 90e9b42bfa2..ee3682e39a8 100644 --- a/src/controller/audio-track-controller.ts +++ b/src/controller/audio-track-controller.ts @@ -206,10 +206,6 @@ 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); @@ -217,7 +213,7 @@ class AudioTrackController extends BasePlaylistController { 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); diff --git a/src/controller/base-stream-controller.ts b/src/controller/base-stream-controller.ts index db6b68cfd5f..bd14d2d7a9b 100644 --- a/src/controller/base-stream-controller.ts +++ b/src/controller/base-stream-controller.ts @@ -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]; diff --git a/src/controller/buffer-controller.ts b/src/controller/buffer-controller.ts index 3fdca27cce4..81ab68854d3 100644 --- a/src/controller/buffer-controller.ts +++ b/src/controller/buffer-controller.ts @@ -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 @@ -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); } diff --git a/src/controller/eme-controller.ts b/src/controller/eme-controller.ts index 40cfd059295..dec0831d26a 100644 --- a/src/controller/eme-controller.ts +++ b/src/controller/eme-controller.ts @@ -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! || [] diff --git a/src/controller/level-helper.ts b/src/controller/level-helper.ts index 14344df0c40..020b3888e9e 100644 --- a/src/controller/level-helper.ts +++ b/src/controller/level-helper.ts @@ -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; } diff --git a/src/controller/subtitle-stream-controller.ts b/src/controller/subtitle-stream-controller.ts index ec1e1257226..c5434dd34c2 100644 --- a/src/controller/subtitle-stream-controller.ts +++ b/src/controller/subtitle-stream-controller.ts @@ -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; diff --git a/src/remux/mp4-remuxer.ts b/src/remux/mp4-remuxer.ts index b5eddc727c1..5cd3608601b 100644 --- a/src/remux/mp4-remuxer.ts +++ b/src/remux/mp4-remuxer.ts @@ -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 @@ -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; } @@ -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; } diff --git a/webpack.config.js b/webpack.config.js index 299a3c13ff3..18410946feb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -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')