Bug 1423465. P7 - GetOwner()->DownloadProgressed() should be called after updating mCanPlayThrough. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 05 Dec 2017 16:01:18 +0800
changeset 708111 c011ea19032868ddecf05ac0f82020fe279f9c98
parent 708110 b30eea4d6dac1972a4f9cc0a6ee2275fc23965f1
child 743098 020a40c53642dce8db145fdd2beaa0cc71a959fc
push id92287
push userjwwang@mozilla.com
push dateWed, 06 Dec 2017 07:32:57 +0000
bugs1423465
milestone59.0a1
Bug 1423465. P7 - GetOwner()->DownloadProgressed() should be called after updating mCanPlayThrough. GetOwner()->DownloadProgressed() will update readyState of the media element which will need to read mCanPlayThrough. MozReview-Commit-ID: EDHlLJjKDoL
dom/media/ChannelMediaDecoder.cpp
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -360,18 +360,16 @@ ChannelMediaDecoder::DurationChanged()
   MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
 }
 
 void
 ChannelMediaDecoder::DownloadProgressed()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
-  AbstractThread::AutoEnter context(AbstractMainThread());
-  GetOwner()->DownloadProgressed();
 
   using StatsPromise = MozPromise<MediaStatistics, bool, true>;
   InvokeAsync(GetStateMachine()->OwnerThread(),
               __func__,
               [
                 playbackStats = mPlaybackStatistics,
                 res = RefPtr<BaseMediaResource>(mResource),
                 duration = mDuration,
@@ -387,16 +385,18 @@ ChannelMediaDecoder::DownloadProgressed(
       __func__,
       [ =, self = RefPtr<ChannelMediaDecoder>(this) ](MediaStatistics aStats) {
         if (IsShutdown()) {
           return;
         }
         mCanPlayThrough = aStats.CanPlayThrough();
         GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
         mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
+        AbstractThread::AutoEnter context(AbstractMainThread());
+        GetOwner()->DownloadProgressed();
       },
       []() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
 }
 
 /* static */ ChannelMediaDecoder::PlaybackRateInfo
 ChannelMediaDecoder::ComputePlaybackRate(const MediaChannelStatistics& aStats,
                                          BaseMediaResource* aResource,
                                          double aDuration)