Bug 1506005 - Remove restriction that there is only one in flight paint at a time, r=nical.
authorBrian Hackett <bhackett1024@gmail.com>
Thu, 08 Nov 2018 16:50:13 -1000
changeset 445813 24370d1616e8dc73dfa89ce3b8dd7f872e7fc636
parent 445812 86591a68c3290ba32b00c88359a9b53bfef09024
child 445814 9a517727a2934d019cb46d5a24d75f82134f3a6d
push id35022
push userdluca@mozilla.com
push dateSun, 11 Nov 2018 09:42:48 +0000
treeherdermozilla-central@237e4c0633fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1506005
milestone65.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 1506005 - Remove restriction that there is only one in flight paint at a time, r=nical.
toolkit/recordreplay/ipc/ChildIPC.cpp
--- a/toolkit/recordreplay/ipc/ChildIPC.cpp
+++ b/toolkit/recordreplay/ipc/ChildIPC.cpp
@@ -427,35 +427,33 @@ SetVsyncObserver(VsyncObserver* aObserve
 static void
 NotifyVsyncObserver()
 {
   if (gVsyncObserver) {
     gVsyncObserver->NotifyVsync(TimeStamp::Now());
   }
 }
 
-// Whether an update has been sent to the compositor for a normal paint, and we
-// haven't reached PaintFromMainThread yet. This is used to preserve the
-// invariant that there can be at most one paint performed between two
-// checkpoints, other than repaints triggered by the debugger.
-static bool gHasActivePaint;
+// How many paints have been started and haven't reached PaintFromMainThread
+// yet. Only accessed on the main thread.
+static int32_t gNumPendingMainThreadPaints;
 
 bool
 OnVsync()
 {
   // In the repainting stress mode, we create a new checkpoint on every vsync
   // message received from the UI process. When we notify the parent about the
   // new checkpoint it will trigger a repaint to make sure that all layout and
   // painting activity can occur when diverged from the recording.
   if (parent::InRepaintStressMode()) {
     CreateCheckpoint();
   }
 
   // After a paint starts, ignore incoming vsyncs until the paint completes.
-  return !gHasActivePaint;
+  return gNumPendingMainThreadPaints == 0;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // Painting
 ///////////////////////////////////////////////////////////////////////////////
 
 // Target buffer for the draw target created by the child process widget, which
 // the compositor thread writes to.
@@ -531,37 +529,39 @@ NotifyPaintStart()
     gPainted = true;
 
     // Repaint failures are not allowed in the repaint stress mode.
     gAllowRepaintFailures =
       Preferences::GetBool("devtools.recordreplay.allowRepaintFailures") &&
       !parent::InRepaintStressMode();
   }
 
-  // A new paint cannot be triggered until the last one finishes and has been
-  // sent to the middleman.
-  MOZ_RELEASE_ASSERT(HasDivergedFromRecording() || !gHasActivePaint);
-
   gNumPendingPaints++;
-  gHasActivePaint = true;
+  gNumPendingMainThreadPaints++;
 
   CreateCheckpoint();
 }
 
 static void
 PaintFromMainThread()
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
-  // There cannot not be any other in flight paints.
-  MOZ_RELEASE_ASSERT(!gNumPendingPaints);
+  gNumPendingMainThreadPaints--;
 
-  // Clear the active flag now that we have completed the paint.
-  MOZ_RELEASE_ASSERT(gHasActivePaint);
-  gHasActivePaint = false;
+  if (gNumPendingMainThreadPaints) {
+    // Another paint started before we were able to finish it here. The draw
+    // target buffer no longer reflects program state at the last checkpoint,
+    // so don't send a Paint message.
+    return;
+  }
+
+  // If all paints have completed, the compositor cannot be simultaneously
+  // operating on the draw target buffer.
+  MOZ_RELEASE_ASSERT(!gNumPendingPaints);
 
   if (IsActiveChild() && gDrawTargetBuffer) {
     memcpy(gGraphicsShmem, gDrawTargetBuffer, gDrawTargetBufferSize);
     gChannel->SendMessage(PaintMessage(navigation::LastNormalCheckpoint(),
                                        gPaintWidth, gPaintHeight));
   }
 }