Bug 1613672 - return `NS_ERROR_DOM_MEDIA_CANCELED` to indicate that track buffer manager has been detached from the demuxer. r=jya
authoralwu <alwu@mozilla.com>
Tue, 22 Dec 2020 06:06:04 +0000
changeset 561645 1c00de8c800ee726863fab0a9245e2c9a8e58136
parent 561644 ab7649dc7fddc8fd9a81a54d61b1e7221fc298ca
child 561646 ed0b7d9cd4879a9ef6aa38c8ca628d3014683f9c
push id38052
push usercsabou@mozilla.com
push dateTue, 22 Dec 2020 21:50:26 +0000
treeherdermozilla-central@be30820869d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1613672
milestone86.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -338,17 +338,17 @@ void MediaSourceTrackDemuxer::BreakCycle
   MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
   Unused << rv;
 }
 
 RefPtr<MediaSourceTrackDemuxer::SeekPromise> 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__);
   }
 
   MOZ_ASSERT(OnTaskQueue());
   TimeIntervals buffered = mManager->Buffered(mType);
   // Fuzz factor represents a +/- threshold. So when seeking it allows the gap
   // to be twice as big as the fuzz value. We only want to allow EOS_FUZZ gap.
@@ -390,17 +390,17 @@ RefPtr<MediaSourceTrackDemuxer::SeekProm
   }
   return SeekPromise::CreateAndResolve(seekTime, __func__);
 }
 
 RefPtr<MediaSourceTrackDemuxer::SamplesPromise>
 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__);
   }
 
   MOZ_ASSERT(OnTaskQueue());
   if (mReset) {
     // If a seek (or reset) was recently performed, we ensure that the data
     // we are about to retrieve is still available.
@@ -446,17 +446,17 @@ MediaSourceTrackDemuxer::DoGetSamples(in
   return SamplesPromise::CreateAndResolve(samples, __func__);
 }
 
 RefPtr<MediaSourceTrackDemuxer::SkipAccessPointPromise>
 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__);
   }
 
   MOZ_ASSERT(OnTaskQueue());
   uint32_t parsed = 0;
   // Ensure that the data we are about to skip to is still available.