Backed out changeset 7f13c7a84acb (bug 1343341) for hitting a fatal assert that it added in RasterImage::OnSurfaceDiscard sometimes on android reftests.
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 02 Mar 2017 02:24:29 -0600
changeset 345596 b92b8655e634c865271a079b7709cb466fa44bdf
parent 345595 2ed30cf5eeb6a86418b440f922c3f1ab8a9c9823
child 345597 c08af8aad4ceb7f9c0eebb46bf0c9e75dfbbbdda
push id31441
push userkwierso@gmail.com
push dateThu, 02 Mar 2017 22:57:54 +0000
treeherdermozilla-central@b23d6277acca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1343341
milestone54.0a1
backs out7f13c7a84acb0eac18b13cf48cca108b4e26b1d0
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
Backed out changeset 7f13c7a84acb (bug 1343341) for hitting a fatal assert that it added in RasterImage::OnSurfaceDiscard sometimes on android reftests.
image/FrameAnimator.cpp
image/FrameAnimator.h
image/RasterImage.cpp
--- a/image/FrameAnimator.cpp
+++ b/image/FrameAnimator.cpp
@@ -23,36 +23,20 @@ namespace image {
 
 ///////////////////////////////////////////////////////////////////////////////
 // AnimationState implementation.
 ///////////////////////////////////////////////////////////////////////////////
 
 void
 AnimationState::NotifyDecodeComplete()
 {
-  // If we weren't discarded before the decode finished then mark ourselves as
-  // currently decoded.
-  if (!mDiscarded) {
-    mIsCurrentlyDecoded = true;
-  }
   mHasBeenDecoded = true;
 }
 
 void
-AnimationState::SetDiscarded(bool aDiscarded)
-{
-  if (aDiscarded) {
-    MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
-    mIsCurrentlyDecoded = false;
-    mCompositedFrameInvalid = true;
-  }
-  mDiscarded = aDiscarded;
-}
-
-void
 AnimationState::ResetAnimation()
 {
   mCurrentAnimationFrameIndex = 0;
 }
 
 void
 AnimationState::SetAnimationMode(uint16_t aAnimationMode)
 {
@@ -276,27 +260,23 @@ FrameAnimator::AdvanceFrame(AnimationSta
   ret.mFrameAdvanced = true;
 
   return ret;
 }
 
 RefreshResult
 FrameAnimator::RequestRefresh(AnimationState& aState, const TimeStamp& aTime)
 {
-  // By default, an empty RefreshResult.
-  RefreshResult ret;
-
-  if (aState.IsDiscarded()) {
-    return ret;
-  }
-
   // only advance the frame if the current time is greater than or
   // equal to the current frame's end time.
   TimeStamp currentFrameEndTime = GetCurrentImgFrameEndTime(aState);
 
+  // By default, an empty RefreshResult.
+  RefreshResult ret;
+
   while (currentFrameEndTime <= aTime) {
     TimeStamp oldFrameEndTime = currentFrameEndTime;
 
     RefreshResult frameRes = AdvanceFrame(aState, aTime);
 
     // Accumulate our result for returning to callers.
     ret.Accumulate(frameRes);
 
@@ -305,36 +285,22 @@ FrameAnimator::RequestRefresh(AnimationS
     // If we didn't advance a frame, and our frame end time didn't change,
     // then we need to break out of this loop & wait for the frame(s)
     // to finish downloading.
     if (!frameRes.mFrameAdvanced && (currentFrameEndTime == oldFrameEndTime)) {
       break;
     }
   }
 
-  // Advanced to the correct frame, the composited frame is now valid to be drawn.
-  if (currentFrameEndTime > aTime) {
-    aState.mCompositedFrameInvalid = false;
-  }
-
-  MOZ_ASSERT(!aState.mIsCurrentlyDecoded || !aState.mCompositedFrameInvalid);
-
   return ret;
 }
 
 LookupResult
 FrameAnimator::GetCompositedFrame(AnimationState& aState)
 {
-  if (aState.mCompositedFrameInvalid) {
-    MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
-    MOZ_ASSERT(aState.GetHasBeenDecoded());
-    MOZ_ASSERT(!aState.GetIsCurrentlyDecoded());
-    return LookupResult(MatchType::NOT_FOUND);
-  }
-
   // If we have a composited version of this frame, return that.
   if (mLastCompositedFrameIndex >= 0 &&
       (uint32_t(mLastCompositedFrameIndex) == aState.mCurrentAnimationFrameIndex)) {
     return LookupResult(DrawableSurface(mCompositingFrame->DrawableRef()),
                         MatchType::EXACT);
   }
 
   // Otherwise return the raw frame. DoBlend is required to ensure that we only
--- a/image/FrameAnimator.h
+++ b/image/FrameAnimator.h
@@ -28,66 +28,29 @@ public:
   explicit AnimationState(uint16_t aAnimationMode)
     : mFrameCount(0)
     , mCurrentAnimationFrameIndex(0)
     , mLoopRemainingCount(-1)
     , mLoopCount(-1)
     , mFirstFrameTimeout(FrameTimeout::FromRawMilliseconds(0))
     , mAnimationMode(aAnimationMode)
     , mHasBeenDecoded(false)
-    , mIsCurrentlyDecoded(false)
-    , mCompositedFrameInvalid(false)
-    , mDiscarded(false)
   { }
 
   /**
    * Call when a decode of this image has been completed.
    */
   void NotifyDecodeComplete();
 
   /**
    * Returns true if this image has been fully decoded before.
    */
   bool GetHasBeenDecoded() { return mHasBeenDecoded; }
 
   /**
-   * Call this with true when this image is discarded. Call this with false
-   * when a decoder is created to decode the image.
-   */
-  void SetDiscarded(bool aDiscarded);
-
-  /**
-   * Returns true if this image has been discarded and a decoded has not yet
-   * been created to redecode it.
-   */
-  bool IsDiscarded() { return mDiscarded; }
-
-  /**
-   * Sets the composited frame as valid or invalid.
-   */
-  void SetCompositedFrameInvalid(bool aInvalid) {
-    MOZ_ASSERT(!aInvalid || gfxPrefs::ImageMemAnimatedDiscardable());
-    mCompositedFrameInvalid = aInvalid;
-  }
-
-  /**
-   * Returns whether the composited frame is valid to draw to the screen.
-   */
-  bool GetCompositedFrameInvalid() {
-    return mCompositedFrameInvalid;
-  }
-
-  /**
-   * Returns whether the image is currently full decoded..
-   */
-  bool GetIsCurrentlyDecoded() {
-    return mIsCurrentlyDecoded;
-  }
-
-  /**
    * Call when you need to re-start animating. Ensures we start from the first
    * frame.
    */
   void ResetAnimation();
 
   /**
    * The animation mode of the image.
    *
@@ -177,54 +140,18 @@ private:
   Maybe<FrameTimeout> mLoopLength;
 
   //! The timeout for the first frame of this image.
   FrameTimeout mFirstFrameTimeout;
 
   //! The animation mode of this image. Constants defined in imgIContainer.
   uint16_t mAnimationMode;
 
-  /**
-   * The following four bools (mHasBeenDecoded, mIsCurrentlyDecoded,
-   * mCompositedFrameInvalid, mDiscarded) track the state of the image with
-   * regards to decoding. They all start out false, including mDiscarded,
-   * because we want to treat being discarded differently from "not yet decoded
-   * for the first time".
-   *
-   * (When we are decoding the image for the first time we want to show the
-   * image at the speed of data coming in from the network or the speed
-   * specified in the image file, whichever is slower. But when redecoding we
-   * want to show nothing until the frame for the current time has been
-   * decoded. The prevents the user from seeing the image "fast forward"
-   * to the expected spot.)
-   *
-   * When the image is decoded for the first time mHasBeenDecoded and
-   * mIsCurrentlyDecoded get set to true. When the image is discarded
-   * mIsCurrentlyDecoded gets set to false, and mCompositedFrameInvalid
-   * & mDiscarded get set to true. When we create a decoder to redecode the
-   * image mDiscarded gets set to false. mCompositedFrameInvalid gets set to
-   * false when we are able to advance to the frame that should be showing
-   * for the current time. mIsCurrentlyDecoded gets set to true when the
-   * redecode finishes.
-   */
-
   //! Whether this image has been decoded at least once.
   bool mHasBeenDecoded;
-
-  //! Whether this image is currently fully decoded.
-  bool mIsCurrentlyDecoded;
-
-  //! Whether the composited frame is valid to draw to the screen, note that
-  //! the composited frame can exist and be filled with image data but not
-  //! valid to draw to the screen.
-  bool mCompositedFrameInvalid;
-
-  //! Whether this image is currently discarded. Only set to true after the
-  //! image has been decoded at least once.
-  bool mDiscarded;
 };
 
 /**
  * RefreshResult is used to let callers know how the state of the animation
  * changed during a call to FrameAnimator::RequestRefresh().
  */
 struct RefreshResult
 {
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -419,21 +419,16 @@ RasterImage::WillDrawOpaqueNow()
   return true;
 }
 
 void
 RasterImage::OnSurfaceDiscarded()
 {
   MOZ_ASSERT(mProgressTracker);
 
-  if (mAnimationState) {
-    MOZ_ASSERT(gfxPrefs::ImageMemAnimatedDiscardable());
-    mAnimationState->SetDiscarded(true);
-  }
-
   NS_DispatchToMainThread(NewRunnableMethod("ProgressTracker::OnDiscard",
                                             mProgressTracker, &ProgressTracker::OnDiscard));
 }
 
 //******************************************************************************
 NS_IMETHODIMP
 RasterImage::GetAnimated(bool* aAnimated)
 {
@@ -1028,20 +1023,16 @@ RasterImage::Discard()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(CanDiscard(), "Asked to discard but can't");
   MOZ_ASSERT(!mAnimationState, "Asked to discard for animated image");
 
   // Delete all the decoded frames.
   SurfaceCache::RemoveImage(ImageKey(this));
 
-  if (mAnimationState) {
-    mAnimationState->SetDiscarded(true);
-  }
-
   // Notify that we discarded.
   if (mProgressTracker) {
     mProgressTracker->OnDiscard();
   }
 }
 
 bool
 RasterImage::CanDiscard() {
@@ -1198,17 +1189,16 @@ RasterImage::Decode(const IntSize& aSize
     // If there's no transparency, it doesn't matter whether we premultiply
     // alpha or not.
     surfaceFlags &= ~SurfaceFlags::NO_PREMULTIPLY_ALPHA;
   }
 
   // Create a decoder.
   RefPtr<IDecodingTask> task;
   if (mAnimationState && aPlaybackType == PlaybackType::eAnimated) {
-    mAnimationState->SetDiscarded(false);
     task = DecoderFactory::CreateAnimationDecoder(mDecoderType, WrapNotNull(this),
                                                   mSourceBuffer, mSize,
                                                   decoderFlags, surfaceFlags);
   } else {
     task = DecoderFactory::CreateDecoder(mDecoderType, WrapNotNull(this),
                                          mSourceBuffer, mSize, aSize,
                                          decoderFlags, surfaceFlags);
   }