Bug 1590619: Only clean up Remote Canvas IPC classes when the CanvasChild owns the only recorder reference. r=jrmuizel
authorBob Owen <bobowencode@gmail.com>
Mon, 04 Nov 2019 14:15:22 +0000
changeset 500393 f9e4f9253b67e7f2c5e57dd47e36a6f2dba0a751
parent 500392 7842d89fdccf2cd64545bc1e54210df7b962e6ed
child 500394 7fa59747bc5df3fb62a8672a53f5c575ae652701
push id36763
push userrmaries@mozilla.com
push dateMon, 04 Nov 2019 21:44:06 +0000
treeherdermozilla-central@75a7a3400888 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1590619
milestone72.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 1590619: Only clean up Remote Canvas IPC classes when the CanvasChild owns the only recorder reference. r=jrmuizel This also removes the DrawEventRecorderPrivate::IsEmpty method as it is no longer used. It doesn't undo the splitting out of the tracking of the UnscaledFonts, which was added at the same time, because I think it is useful to highlight the fact that they are never currently removed. Differential Revision: https://phabricator.services.mozilla.com/D51593
gfx/2d/DrawEventRecorder.h
gfx/layers/ipc/CanvasChild.cpp
--- a/gfx/2d/DrawEventRecorder.h
+++ b/gfx/2d/DrawEventRecorder.h
@@ -46,21 +46,16 @@ class DrawEventRecorderPrivate : public 
          surface != mStoredSurfaces.end();) {
       auto oldSurface = surface++;
       (*oldSurface)->RemoveUserData(reinterpret_cast<UserDataKey*>(this));
     }
     mStoredFonts.clear();
     mStoredSurfaces.clear();
   }
 
-  bool IsEmpty() {
-    // ScaledFonts aren't added to mStoredObjects, so we need to check both.
-    return mStoredObjects.empty() && mScaledFonts.empty();
-  }
-
   void ClearResources() {
     mStoredObjects.clear();
     mStoredFontData.clear();
     mScaledFonts.clear();
   }
 
   template <class S>
   void WriteHeader(S& aStream) {
--- a/gfx/layers/ipc/CanvasChild.cpp
+++ b/gfx/layers/ipc/CanvasChild.cpp
@@ -195,18 +195,18 @@ void CanvasChild::EndTransaction() {
     mIsInTransaction = false;
     mLastNonEmptyTransaction = TimeStamp::NowLoRes();
   }
 
   ++mTransactionsSinceGetDataSurface;
 }
 
 bool CanvasChild::ShouldBeCleanedUp() const {
-  // We can't be cleaned up if we have stored objects still alive.
-  if (!mRecorder->IsEmpty()) {
+  // We can only be cleaned up if nothing else references our recorder.
+  if (!mRecorder->hasOneRef()) {
     return false;
   }
 
   static const TimeDuration kCleanUpCanvasThreshold =
       TimeDuration::FromSeconds(10);
   return TimeStamp::NowLoRes() - mLastNonEmptyTransaction >
          kCleanUpCanvasThreshold;
 }