Bug 1222308. Assume frames that are very old will never be composited. r=nical
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 06 Nov 2015 16:56:34 +1300
changeset 271630 d907f1abdcf6f705e2554399218fe010a6b151a8
parent 271629 efc887974a0c606a59ca07b8f2d7edf60ac7dcfe
child 271631 4761642b93dc865f060d3f4e900282b33d394e1a
push id67716
push userrocallahan@mozilla.com
push dateSat, 07 Nov 2015 03:45:15 +0000
treeherdermozilla-inbound@d907f1abdcf6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1222308
milestone45.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 1222308. Assume frames that are very old will never be composited. r=nical This also makes NotifyCompositeInternal take O(N) time in the length of mFrameIDsNotYetComposited instead of O(N^2).
gfx/layers/ImageContainer.cpp
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -257,16 +257,24 @@ ImageContainer::SetCurrentImageInternal(
             img.mTimeStamp >= aImages[0].mTimeStamp) {
           break;
         }
         if (!img.mComposited && !img.mTimeStamp.IsNull() &&
             img.mFrameID != aImages[0].mFrameID) {
           mFrameIDsNotYetComposited.AppendElement(img.mFrameID);
         }
       }
+
+      // Remove really old frames, assuming they'll never be composited.
+      const uint32_t maxFrames = 100;
+      if (mFrameIDsNotYetComposited.Length() > maxFrames) {
+        uint32_t dropFrames = mFrameIDsNotYetComposited.Length() - maxFrames;
+        mDroppedImageCount += dropFrames;
+        mFrameIDsNotYetComposited.RemoveElementsAt(0, dropFrames);
+      }
     }
   }
 
   nsTArray<OwningImage> newImages;
 
   for (uint32_t i = 0; i < aImages.Length(); ++i) {
     NS_ASSERTION(aImages[i].mImage, "image can't be null");
     NS_ASSERTION(!aImages[i].mTimeStamp.IsNull() || aImages.Length() == 1,
@@ -392,26 +400,27 @@ ImageContainer::NotifyCompositeInternal(
   ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   // An image composition notification is sent the first time a particular
   // image is composited by an ImageHost. Thus, every time we receive such
   // a notification, a new image has been painted.
   ++mPaintCount;
 
   if (aNotification.producerID() == mCurrentProducerID) {
-    while (!mFrameIDsNotYetComposited.IsEmpty()) {
-      if (mFrameIDsNotYetComposited[0] <= aNotification.frameID()) {
-        if (mFrameIDsNotYetComposited[0] < aNotification.frameID()) {
+    uint32_t i;
+    for (i = 0; i < mFrameIDsNotYetComposited.Length(); ++i) {
+      if (mFrameIDsNotYetComposited[i] <= aNotification.frameID()) {
+        if (mFrameIDsNotYetComposited[i] < aNotification.frameID()) {
           ++mDroppedImageCount;
         }
-        mFrameIDsNotYetComposited.RemoveElementAt(0);
       } else {
         break;
       }
     }
+    mFrameIDsNotYetComposited.RemoveElementsAt(0, i);
     for (auto& img : mCurrentImages) {
       if (img.mFrameID == aNotification.frameID()) {
         img.mComposited = true;
       }
     }
   }
 
   if (!aNotification.imageTimeStamp().IsNull()) {