Bug 1538023 - Change MDSM::HasLowBufferedData() to consider data buffered after end of decoded data rather than start. r=jya
authorChris Pearce <cpearce@mozilla.com>
Wed, 08 May 2019 04:35:32 +0000
changeset 534895 98918b9e369c5fb7bc421349862c3ffd09b89c8b
parent 534894 8e38a89a6d652b199a048628d7d1aa633ae930bd
child 534896 9d883ff1a903085737c94bb08362dedb7490a313
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1538023
milestone68.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 1538023 - Change MDSM::HasLowBufferedData() to consider data buffered after end of decoded data rather than start. r=jya When under pressure, the MediaCache evicts data before the last read on a stream. We typically have two demuxers reading from different offsets in a stream. So if the MediaCache is under pressure, it may end up evicting data between the two demuxers. The MediaDecoderStateMachine currently goes into buffering state if there's insufficient data available beginning at the start of its queue of decoded samples. However since the MediaCache evicts data behind the streams read cursor, the data after the beginning of the sample queue may have already been evicted by the media cache. This will cause the MediaDecoderStateMachine to enter a buffering state, and if its sample queues are full, there will be no demuxers reading to cause the MediaCache to download the data between the two demuxers, and we'll get stuck in buffering state indefinitely. So change the MediaDecoderStateMachine to instead check whether there's insufficient data available at the end of the decoded sample queues. This means we won't get stuck in buffering state. Note the MediaCache may still evict data which the other demuxer needed, causing us to re-request it, but at least we won't get stuck in buffering state. Differential Revision: https://phabricator.services.mozilla.com/D30310
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -3269,22 +3269,22 @@ bool MediaDecoderStateMachine::HasLowBuf
   if (mBuffered.Ref().IsInvalid()) {
     return false;
   }
 
   // We are never low in decoded data when we don't have audio/video or have
   // decoded all audio/video samples.
   TimeUnit endOfDecodedVideo = (HasVideo() && !VideoQueue().IsFinished())
                                    ? mDecodedVideoEndTime
-                                   : TimeUnit::FromInfinity();
+                                   : TimeUnit::FromNegativeInfinity();
   TimeUnit endOfDecodedAudio = (HasAudio() && !AudioQueue().IsFinished())
                                    ? mDecodedAudioEndTime
-                                   : TimeUnit::FromInfinity();
-
-  auto endOfDecodedData = std::min(endOfDecodedVideo, endOfDecodedAudio);
+                                   : TimeUnit::FromNegativeInfinity();
+
+  auto endOfDecodedData = std::max(endOfDecodedVideo, endOfDecodedAudio);
   if (Duration() < endOfDecodedData) {
     // Our duration is not up to date. No point buffering.
     return false;
   }
 
   if (endOfDecodedData.IsInfinite()) {
     // Have decoded all samples. No point buffering.
     return false;