Bug 1456561 - Reduce the number of WakeSceneBuilder messages. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 24 Apr 2018 18:54:45 -0400
changeset 471557 5934ceb7311587a6b096401d4b2058a2d13933d6
parent 471556 4a75b60fccb6c73dc37e804f38b076dbf9c4c1c4
child 471558 ee12eb319b24369ecc956afacad532c56b44808b
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1456561
milestone61.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 1456561 - Reduce the number of WakeSceneBuilder messages. r=botond Avoid sending a flood of WakeSceneBuilder messages when we get a series of updater-thread tasks to run in quick succession. MozReview-Commit-ID: 2irXrsahMPt
gfx/layers/apz/src/APZUpdater.cpp
--- a/gfx/layers/apz/src/APZUpdater.cpp
+++ b/gfx/layers/apz/src/APZUpdater.cpp
@@ -357,30 +357,45 @@ APZUpdater::RunOnUpdaterThread(LayersId 
   }
 
   if (UsingWebRenderUpdaterThread()) {
     // If the updater thread is a WebRender thread, and we're not on it
     // right now, save the task in the queue. We will run tasks from the queue
     // during the callback from the updater thread, which we trigger by the
     // call to WakeSceneBuilder.
 
+    bool sendWakeMessage = true;
     { // scope lock
       MutexAutoLock lock(mQueueLock);
+      for (const auto& queuedTask : mUpdaterQueue) {
+        if (queuedTask.mLayersId == aLayersId) {
+          // If there's already a task in the queue with this layers id, then
+          // we must have previously sent a WakeSceneBuilder message (when
+          // adding the first task with this layers id to the queue). Either
+          // that hasn't been fully processed yet, or the layers id is blocked
+          // waiting for an epoch - in either case there's no point in sending
+          // another WakeSceneBuilder message.
+          sendWakeMessage = false;
+          break;
+        }
+      }
       mUpdaterQueue.push_back(QueuedTask { aLayersId, task });
     }
-    RefPtr<wr::WebRenderAPI> api = mApz->GetWebRenderAPI();
-    if (api) {
-      api->WakeSceneBuilder();
-    } else {
-      // Not sure if this can happen, but it might be possible. If it does,
-      // the task is in the queue, but if we didn't get a WebRenderAPI it
-      // might never run, or it might run later if we manage to get a
-      // WebRenderAPI later. For now let's just emit a warning, this can
-      // probably be upgraded to an assert later.
-      NS_WARNING("Possibly dropping task posted to updater thread");
+    if (sendWakeMessage) {
+      RefPtr<wr::WebRenderAPI> api = mApz->GetWebRenderAPI();
+      if (api) {
+        api->WakeSceneBuilder();
+      } else {
+        // Not sure if this can happen, but it might be possible. If it does,
+        // the task is in the queue, but if we didn't get a WebRenderAPI it
+        // might never run, or it might run later if we manage to get a
+        // WebRenderAPI later. For now let's just emit a warning, this can
+        // probably be upgraded to an assert later.
+        NS_WARNING("Possibly dropping task posted to updater thread");
+      }
     }
     return;
   }
 
   if (MessageLoop* loop = CompositorThreadHolder::Loop()) {
     loop->PostTask(task.forget());
   } else {
     // Could happen during startup