Bug 1404749: Release our DrawTargetCapture on the main thread. r=mattwoodrow
MozReview-Commit-ID: 7uRdl2ZWtGS
--- 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);