Bug 1501212 - Fix faulty assert when requesting a frame from a previously discarded animated image. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Tue, 23 Oct 2018 08:20:04 -0400
changeset 443104 b412e9d74e5770ef2531ca603dbc29df93316009
parent 443103 1fab862943ad9963334fc04eb55a7539197ec0f4
child 443105 dc8601554a38bdd9ed08d3aee628ec313baae56a
child 443143 a79126bab347bcb78193e156800178f9227ab294
push id109297
push useraosmond@gmail.com
push dateFri, 26 Oct 2018 11:50:53 +0000
treeherdermozilla-inbound@b412e9d74e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1501212
milestone65.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 1501212 - Fix faulty assert when requesting a frame from a previously discarded animated image. r=tnikkel We should only assert that the caller is requesting the first frame or we have advanced to or beyond the expected initial frame, when we successfully return a frame. This is because FrameAnimator will request on refresh ticks for the current frame again, until it observes it. If decoding is still behind, then we likely still have frames to auto-advance, and we will trip the assert. Differential Revision: https://phabricator.services.mozilla.com/D9507
image/AnimationFrameBuffer.cpp
--- a/image/AnimationFrameBuffer.cpp
+++ b/image/AnimationFrameBuffer.cpp
@@ -235,20 +235,16 @@ AnimationFrameDiscardingQueue::AdvanceIn
     // do not have any pending, then we know that there is no active decoding.
     mPending += mBatch;
   }
 }
 
 imgFrame*
 AnimationFrameDiscardingQueue::Get(size_t aFrame, bool aForDisplay)
 {
-  // If we are advancing on behalf of the animation, we don't expect it to be
-  // getting any frames (besides the first) until we get the desired frame.
-  MOZ_ASSERT(aFrame == 0 || mAdvance == 0);
-
   // The first frame is stored separately. If we only need the frame for
   // display purposes, we can return it right away. If we need it for advancing
   // the animation, we want to verify the recreated first frame is available
   // before allowing it continue.
   if (aForDisplay && aFrame == 0) {
     return mFirstFrame.get();
   }
 
@@ -266,16 +262,20 @@ AnimationFrameDiscardingQueue::Get(size_
   } else {
     offset = mSize - mGetIndex + aFrame;
   }
 
   if (offset >= mDisplay.size()) {
     return nullptr;
   }
 
+  // If we are advancing on behalf of the animation, we don't expect it to be
+  // getting any frames (besides the first) until we get the desired frame.
+  MOZ_ASSERT(aFrame == 0 || mAdvance == 0);
+
   // If we have space for the frame, it should always be available.
   MOZ_ASSERT(mDisplay[offset]);
   return mDisplay[offset].get();
 }
 
 bool
 AnimationFrameDiscardingQueue::IsFirstFrameFinished() const
 {