Bug 1404749: Release our DrawTargetCapture on the main thread. r=mattwoodrow draft
authorBas Schouten <bschouten@mozilla.com>
Mon, 02 Oct 2017 00:53:33 +0200
changeset 673169 e4c6370f372d5d2d7fb09cba10d0fe0693d9be7d
parent 673168 7667e2b40236a5e7d94c4353268a509f31cc026d
child 673170 fd60f83f8b2d2f1c053977143f2ea3d0adfcd990
push id82481
push userbschouten@mozilla.com
push dateSun, 01 Oct 2017 22:55:31 +0000
reviewersmattwoodrow
bugs1404749
milestone58.0a1
Bug 1404749: Release our DrawTargetCapture on the main thread. r=mattwoodrow MozReview-Commit-ID: 7uRdl2ZWtGS
gfx/layers/PaintThread.cpp
gfx/thebes/gfxPrefs.h
modules/libpref/init/all.js
--- a/gfx/layers/PaintThread.cpp
+++ b/gfx/layers/PaintThread.cpp
@@ -195,16 +195,23 @@ PaintThread::AsyncPaintContents(Composit
     return;
   }
 
   // Draw all the things into the actual dest target.
   target->DrawCapturedDT(capture, Matrix());
   if (!mDrawTargetsToFlush.Contains(target)) {
     mDrawTargetsToFlush.AppendElement(target);
   }
+
+  if (gfxPrefs::LayersOMTPReleaseCaptureOnMainThread()) {
+    // This should ensure the capture drawtarget, which may hold on to UnscaledFont objects,
+    // gets destroyed on the main thread (See bug 1404742). This assumes (unflushed) target
+    // DrawTargets do not themselves hold on to UnscaledFonts.
+    NS_ReleaseOnMainThreadSystemGroup("CapturePaintState::DrawTargetCapture", aState->mCapture.forget());
+  }
 }
 
 void
 PaintThread::EndLayer()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   RefPtr<PaintThread> self = this;
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -614,16 +614,17 @@ private:
   DECL_GFX_PREF(Once, "layers.mlgpu.enable-cpu-occlusion",     AdvancedLayersEnableCPUOcclusion, bool, true);
   DECL_GFX_PREF(Once, "layers.mlgpu.enable-depth-buffer",      AdvancedLayersEnableDepthBuffer, bool, false);
   DECL_GFX_PREF(Live, "layers.mlgpu.enable-invalidation",      AdvancedLayersUseInvalidation, bool, true);
   DECL_GFX_PREF(Once, "layers.mlgpu.enable-on-windows7",       AdvancedLayersEnableOnWindows7, bool, false);
   DECL_GFX_PREF(Once, "layers.mlgpu.enable-container-resizing", AdvancedLayersEnableContainerResizing, bool, true);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-disabled", LayersOffMainThreadCompositionForceDisabled, bool, false);
   DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
   DECL_GFX_PREF(Live, "layers.omtp.force-sync",                LayersOMTPForceSync, bool, false);
+  DECL_GFX_PREF(Live, "layers.omtp.release-capture-on-main-thread", LayersOMTPReleaseCaptureOnMainThread, bool, true);
   DECL_GFX_PREF(Live, "layers.orientation.sync.timeout",       OrientationSyncMillis, uint32_t, (uint32_t)0);
   DECL_GFX_PREF(Once, "layers.prefer-opengl",                  LayersPreferOpenGL, bool, false);
   DECL_GFX_PREF(Live, "layers.progressive-paint",              ProgressivePaint, bool, false);
   DECL_GFX_PREF(Live, "layers.shared-buffer-provider.enabled", PersistentBufferProviderSharedEnabled, bool, false);
   DECL_GFX_PREF(Live, "layers.single-tile.enabled",            LayersSingleTileEnabled, bool, true);
   DECL_GFX_PREF(Once, "layers.stereo-video.enabled",           StereoVideoEnabled, bool, false);
   DECL_GFX_PREF(Live, "layers.force-synchronous-resize",       LayersForceSynchronousResize, bool, true);
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5910,9 +5910,10 @@ pref("toolkit.crashreporter.include_cont
 #else
 pref("toolkit.crashreporter.include_context_heap", true);
 #endif
 
 // Open noopener links in a new process
 pref("dom.noopener.newprocess.enabled", true);
 
 pref("layers.omtp.enabled", false);
+pref("layers.omtp.release-capture-on-main-thread", true);
 pref("layers.omtp.force-sync", false);