Bug 1504060 - Log instead of asserting that webm samples do not have timestamps > segment druation. r=alwu
authorBryce Van Dyk <bvandyk@mozilla.com>
Fri, 01 Mar 2019 18:20:00 +0000
changeset 519870 2d1930ba617fd4ab61d0c427b570faedd632aa34
parent 519869 691151398b918fc80727c8bdd77ad75c478f4a3d
child 519871 83a0072bff1b0066b1d58f59bcd4aaa1842ddff2
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalwu
bugs1504060
milestone67.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 1504060 - Log instead of asserting that webm samples do not have timestamps > segment druation. r=alwu We're able to hit this assertion in the wild due to bad muxers. As such, replace the assert with a log. If a sample has a time stamp > the segment duration, use that instead of the duration for calculating our next time stamp. Use an explicit int64_t type in the signature for our next time stamp calculation as the logging explicitly expects an int64_t (makes it harder to change the types involved and footgunning by having a wrong formatter in the logs). Differential Revision: https://phabricator.services.mozilla.com/D21717
dom/media/webm/WebMDemuxer.cpp
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -551,32 +551,39 @@ nsresult WebMDemuxer::GetNextPacket(Trac
   RefPtr<NesteggPacketHolder> next_holder;
   rv = NextPacket(aType, next_holder);
   if (NS_FAILED(rv) && rv != NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
     return rv;
   }
 
   int64_t next_tstamp = INT64_MIN;
   auto calculateNextTimestamp = [&](auto&& pushPacket, auto&& lastFrameTime,
-                                    auto&& trackEndTime) {
+                                    int64_t trackEndTime) {
     if (next_holder) {
       next_tstamp = next_holder->Timestamp();
       (this->*pushPacket)(next_holder);
     } else if (duration >= 0) {
       next_tstamp = tstamp + duration;
     } else if (lastFrameTime.isSome()) {
       next_tstamp = tstamp + (tstamp - lastFrameTime.ref());
     } else if (mIsMediaSource) {
       (this->*pushPacket)(holder);
     } else {
       // If we can't get frame's duration, it means either we need to wait for
       // more data for MSE case or this is the last frame for file resource
       // case.
-      MOZ_ASSERT(trackEndTime >= tstamp);
-      next_tstamp = trackEndTime;
+      if (tstamp > trackEndTime) {
+        // This shouldn't happen, but some muxers give incorrect durations to
+        // segments, then have samples appear beyond those durations.
+        WEBM_DEBUG("Found tstamp=%" PRIi64 " > trackEndTime=%" PRIi64
+                   " while calculating next timestamp! Indicates a bad mux! "
+                   "Will use tstamp value.",
+                   tstamp, trackEndTime);
+      }
+      next_tstamp = std::max<int64_t>(tstamp, trackEndTime);
     }
     lastFrameTime = Some(tstamp);
   };
 
   if (aType == TrackInfo::kAudioTrack) {
     calculateNextTimestamp(&WebMDemuxer::PushAudioPacket, mLastAudioFrameTime,
                            mInfo.mAudio.mDuration.ToMicroseconds());
   } else {