Bug 847223. Part 9. Try to avoid asking for a decode of an image whose network request finishes before painting is unsuppressed. r=joe,mats
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 14 Sep 2013 19:05:05 -0500
changeset 160156 f2ff265af286887be976495d151fb8534afa9b07
parent 160155 412e57718425328be0adee851a5877c624e0ff11
child 160157 daa9550337abd1993711dd5d6056d9fb658aef2b
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe, mats
bugs847223
milestone26.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 847223. Part 9. Try to avoid asking for a decode of an image whose network request finishes before painting is unsuppressed. r=joe,mats
content/base/src/nsImageLoadingContent.cpp
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -232,18 +232,26 @@ nsImageLoadingContent::OnStopRequest(img
   // XXXkhuey should this be GetOurCurrentDoc?  Decoding if we're not in
   // the document seems silly.
   bool startedDecoding = false;
   nsIDocument* doc = GetOurOwnerDoc();
   nsIPresShell* shell = doc ? doc->GetShell() : nullptr;
   if (shell && shell->IsVisible() &&
       (!shell->DidInitialize() || shell->IsPaintingSuppressed())) {
 
-    if (NS_SUCCEEDED(mCurrentRequest->StartDecoding())) {
-      startedDecoding = true;
+    // If we've gotten a frame and that frame has called FrameCreate and that
+    // frame has been reflowed then we know that it checked it's own visibility
+    // so we can trust our visible count and we don't start decode if we are not
+    // visible.
+    nsIFrame* f = GetOurPrimaryFrame();
+    if (!mFrameCreateCalled || !f ||
+        (f->GetStateBits() & NS_FRAME_FIRST_REFLOW) || mVisibleCount > 0) {
+      if (NS_SUCCEEDED(mCurrentRequest->StartDecoding())) {
+        startedDecoding = true;
+      }
     }
   }
 
   // We want to give the decoder a chance to find errors. If we haven't found
   // an error yet and we've started decoding, either from the above
   // StartDecoding or from some other place, we must only fire these events
   // after we finish decoding.
   uint32_t reqStatus;