Bug 937878 - Don't let too many ContentHostIncremental updates queue up. r=nrc
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 15 Nov 2013 12:56:42 +1300
changeset 154961 1f3975482a971893ad769d2392c5f0195988475d
parent 154960 b4c82e9838d51fe35c0cd489913ad6aff29fe7c0
child 154962 6887b71d36ee952e9bd3fcf0758e2ecbddf15908
push id25657
push userMs2ger@gmail.com
push dateSun, 17 Nov 2013 13:24:50 +0000
treeherdermozilla-central@0e88f511e067 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc
bugs937878
milestone28.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 937878 - Don't let too many ContentHostIncremental updates queue up. r=nrc
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ContentHost.h
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -490,31 +490,46 @@ ContentHostDoubleBuffered::UpdateThebes(
 void
 ContentHostIncremental::EnsureDeprecatedTextureHostIncremental(ISurfaceAllocator* aAllocator,
                                                      const TextureInfo& aTextureInfo,
                                                      const nsIntRect& aBufferRect)
 {
   mUpdateList.AppendElement(new TextureCreationRequest(aTextureInfo,
                                                        aBufferRect));
   mDeAllocator = aAllocator;
+  FlushUpdateQueue();
 }
 
 void
 ContentHostIncremental::UpdateIncremental(TextureIdentifier aTextureId,
                                           SurfaceDescriptor& aSurface,
                                           const nsIntRegion& aUpdated,
                                           const nsIntRect& aBufferRect,
                                           const nsIntPoint& aBufferRotation)
 {
   mUpdateList.AppendElement(new TextureUpdateRequest(mDeAllocator,
                                                      aTextureId,
                                                      aSurface,
                                                      aUpdated,
                                                      aBufferRect,
                                                      aBufferRotation));
+  FlushUpdateQueue();
+}
+
+void
+ContentHostIncremental::FlushUpdateQueue()
+{
+  // If we're not compositing for some reason (the window being minimized
+  // is one example), then we never process these updates and it can consume
+  // huge amounts of memory. Instead we forcibly process the updates (during the
+  // transaction) if the list gets too long.
+  static const uint32_t kMaxUpdateCount = 6;
+  if (mUpdateList.Length() >= kMaxUpdateCount) {
+    ProcessTextureUpdates();
+  }
 }
 
 void
 ContentHostIncremental::ProcessTextureUpdates()
 {
   for (uint32_t i = 0; i < mUpdateList.Length(); i++) {
     mUpdateList[i]->Execute(this);
   }
--- a/gfx/layers/composite/ContentHost.h
+++ b/gfx/layers/composite/ContentHost.h
@@ -291,16 +291,17 @@ public:
   {
     mDeprecatedTextureHost = nullptr;
     mDeprecatedTextureHostOnWhite = nullptr;
     mUpdateList.Clear();
   }
 
 private:
 
+  void FlushUpdateQueue();
   void ProcessTextureUpdates();
 
   class Request
   {
   public:
     Request()
     {
       MOZ_COUNT_CTOR(ContentHostIncremental::Request);