From e77464e77c4de438c475ca3ca0abdfd3cbabac1d Mon Sep 17 00:00:00 2001 From: alwu Date: Tue, 22 Dec 2020 06:06:04 +0000 Subject: [PATCH] Bug 1613672 - return `NS_ERROR_DOM_MEDIA_CANCELED` to indicate that track buffer manager has been detached from the demuxer. r=jya When we shutdown `MediaSourceDecoder`, it would trigger a shutdown for `MDSM` and a detaching for media source. In the previous one, that would eventually shutdown `MediaFormatReader` via tasks going through different threads (main->MDSM->MFR's supervisor). In the latter one, it would eventually detach the `TrackBufferManager` from the `MediaSourceTrackDemuxer`. (main->Demuxer's supervisor) As these two tasks running in different threads, and the latter usually get finished before the former one, which would result in `MediaSourceTrackDemuxer` no longer being able to get a sample. When that happens, the reader hasn't been shutdown yet, so it's still holding track demuxers and keeps requesting data from them. Then demuxers would return error because their corresponding track managers have been detached. The reader would report the demuxing error to the console, but that's acutally not a fatal error, because in this situation the reader is going to be shutdown soon. Therefore, return `NS_ERROR_DOM_MEDIA_CANCELED` to allow MFR to treat this error differently. Differential Revision: https://phabricator.services.mozilla.com/D100153 --- dom/media/mediasource/MediaSourceDemuxer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dom/media/mediasource/MediaSourceDemuxer.cpp b/dom/media/mediasource/MediaSourceDemuxer.cpp index eee9be7650e2..3b4903446444 100644 --- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -343,7 +343,7 @@ RefPtr MediaSourceTrackDemuxer::DoSeek( const TimeUnit& aTime) { if (!mManager) { return SeekPromise::CreateAndReject( - MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, + MediaResult(NS_ERROR_DOM_MEDIA_CANCELED, RESULT_DETAIL("manager is detached.")), __func__); } @@ -395,7 +395,7 @@ RefPtr MediaSourceTrackDemuxer::DoGetSamples(int32_t aNumSamples) { if (!mManager) { return SamplesPromise::CreateAndReject( - MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, + MediaResult(NS_ERROR_DOM_MEDIA_CANCELED, RESULT_DETAIL("manager is detached.")), __func__); } @@ -451,7 +451,7 @@ MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint( const TimeUnit& aTimeThreadshold) { if (!mManager) { return SkipAccessPointPromise::CreateAndReject( - SkipFailureHolder(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, + SkipFailureHolder(MediaResult(NS_ERROR_DOM_MEDIA_CANCELED, RESULT_DETAIL("manager is detached.")), 0), __func__);