diff --git a/api-extractor/report/hls.js.api.md b/api-extractor/report/hls.js.api.md index 7575aed8cfb..65cdb1e3498 100644 --- a/api-extractor/report/hls.js.api.md +++ b/api-extractor/report/hls.js.api.md @@ -524,7 +524,11 @@ export class BufferController implements ComponentAPI { // (undocumented) protected appendChangeType(type: any, mimeType: any): void; // (undocumented) - appendError: number; + appendErrors: { + audio: number; + video: number; + audiovideo: number; + }; // (undocumented) bufferCodecEventsExpected: number; // (undocumented) @@ -977,10 +981,14 @@ export interface ErrorData { // (undocumented) parent?: PlaylistLevelType; // (undocumented) + part?: Part | null; + // (undocumented) reason?: string; // (undocumented) response?: LoaderResponse; // (undocumented) + sourceBufferName?: SourceBufferName; + // (undocumented) stats?: LoaderStats; // (undocumented) type: ErrorTypes; diff --git a/src/controller/buffer-controller.ts b/src/controller/buffer-controller.ts index 3df684536ce..a1557d985e8 100644 --- a/src/controller/buffer-controller.ts +++ b/src/controller/buffer-controller.ts @@ -23,6 +23,7 @@ import type { BufferFlushingData, FragParsedData, FragChangedData, + ErrorData, } from '../types/events'; import type { ComponentAPI } from '../types/component-api'; import type { ChunkMetadata } from '../types/transmuxer'; @@ -61,7 +62,11 @@ export default class BufferController implements ComponentAPI { private lastMpegAudioChunk: ChunkMetadata | null = null; // counters - public appendError: number = 0; + public appendErrors = { + audio: 0, + video: 0, + audiovideo: 0, + }; public tracks: TrackSet = {}; public pendingTracks: TrackSet = {}; @@ -400,7 +405,7 @@ export default class BufferController implements ComponentAPI { for (const type in sourceBuffer) { timeRanges[type] = BufferHelper.getBuffered(sourceBuffer[type]); } - this.appendError = 0; + this.appendErrors[type] = 0; this.hls.trigger(Events.BUFFER_APPENDED, { type, frag, @@ -412,10 +417,11 @@ export default class BufferController implements ComponentAPI { }, onError: (err) => { // in case any error occured while appending, put back segment in segments table - const event = { + const event: ErrorData = { type: ErrorTypes.MEDIA_ERROR, parent: frag.type, details: ErrorDetails.BUFFER_APPEND_ERROR, + sourceBufferName: type, frag, part, chunkMeta, @@ -429,15 +435,15 @@ export default class BufferController implements ComponentAPI { // let's stop appending any segments, and report BUFFER_FULL_ERROR error event.details = ErrorDetails.BUFFER_FULL_ERROR; } else { - this.appendError++; + const appendErrorCount = ++this.appendErrors[type]; event.details = ErrorDetails.BUFFER_APPEND_ERROR; /* with UHD content, we could get loop of quota exceeded error until browser is able to evict some data from sourcebuffer. Retrying can help recover. */ - if (this.appendError > hls.config.appendErrorMaxRetry) { - this.error( - `Failed ${hls.config.appendErrorMaxRetry} times to append segment in sourceBuffer` - ); + this.warn( + `Failed ${appendErrorCount}/${hls.config.appendErrorMaxRetry} times to append segment in "${type}" sourceBuffer` + ); + if (appendErrorCount > hls.config.appendErrorMaxRetry) { event.fatal = true; } } @@ -779,6 +785,7 @@ export default class BufferController implements ComponentAPI { details: ErrorDetails.BUFFER_ADD_CODEC_ERROR, fatal: false, error: err, + sourceBufferName: trackName as SourceBufferName, mimeType: mimeType, }); } @@ -841,6 +848,7 @@ export default class BufferController implements ComponentAPI { this.hls.trigger(Events.ERROR, { type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_APPENDING_ERROR, + sourceBufferName: type, error, fatal: false, }); diff --git a/src/types/events.ts b/src/types/events.ts index 53ede3da7f8..a68b02a3bd0 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -233,6 +233,7 @@ export interface ErrorData { context?: PlaylistLoaderContext; event?: keyof HlsListeners | 'demuxerWorker'; frag?: Fragment; + part?: Part | null; level?: number | undefined; levelRetry?: boolean; loader?: Loader; @@ -243,6 +244,7 @@ export interface ErrorData { response?: LoaderResponse; url?: string; parent?: PlaylistLevelType; + sourceBufferName?: SourceBufferName; /** * @deprecated Use ErrorData.error */ diff --git a/tests/unit/controller/buffer-controller-operations.ts b/tests/unit/controller/buffer-controller-operations.ts index df2f6a314b5..3fbdca8a1b5 100644 --- a/tests/unit/controller/buffer-controller-operations.ts +++ b/tests/unit/controller/buffer-controller-operations.ts @@ -161,6 +161,7 @@ describe('BufferController', function () { ).to.have.been.calledWith(Events.ERROR, { type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_APPENDING_ERROR, + sourceBufferName: triggerSpy.getCall(0).lastArg.sourceBufferName, error: triggerSpy.getCall(0).lastArg.error, fatal: false, }); @@ -251,6 +252,7 @@ describe('BufferController', function () { ).to.have.been.calledWith(Events.ERROR, { type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_APPEND_ERROR, + sourceBufferName: triggerSpy.getCall(0).lastArg.sourceBufferName, parent: 'main', frag, part: undefined,