Bug 913138 - Shut down gfx at the end of layout shutdown. r=bsmedberg
authorBobby Holley <bobbyholley@gmail.com>
Tue, 08 Apr 2014 15:51:33 -0700
changeset 177634 28c0f1bcfd172c011ca963f02a2335fc67383810
parent 177633 c6ccf0698fa1771d3b10f39c13aa5da4ae299076
child 177635 118273e2a6564097a044565cebeebec3080542d4
push id26558
push usercbook@mozilla.com
push dateWed, 09 Apr 2014 12:19:15 +0000
treeherdermozilla-central@c4979703f76a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs913138
milestone31.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 913138 - Shut down gfx at the end of layout shutdown. r=bsmedberg
gfx/src/nsThebesGfxFactory.cpp
gfx/thebes/gfxPlatform.cpp
layout/build/nsLayoutModule.cpp
--- a/gfx/src/nsThebesGfxFactory.cpp
+++ b/gfx/src/nsThebesGfxFactory.cpp
@@ -13,30 +13,16 @@
 #include "nsError.h"                    // for NS_ERROR_NO_AGGREGATION, etc
 #include "nsGfxCIID.h"                  // for NS_FONT_ENUMERATOR_CID, etc
 #include "nsID.h"                       // for NS_DEFINE_NAMED_CID, etc
 #include "nsIScriptableRegion.h"        // for nsIScriptableRegion
 #include "nsISupports.h"                // for NS_DECL_ISUPPORTS, etc
 #include "nsScriptableRegion.h"         // for nsScriptableRegion
 #include "nsThebesFontEnumerator.h"     // for nsThebesFontEnumerator
 
-// This class doesn't do anything; its only purpose is to give
-// gfxPlatform::Init a way to force this component to be registered,
-// so that gfxPlatform::Shutdown will be called at an appropriate
-// time.  (Component teardown is the only shutdown hook that runs
-// late enough; see bug 651498.)
-
-namespace {
-class GfxInitialization MOZ_FINAL : public nsISupports {
-    NS_DECL_ISUPPORTS
-};
-
-NS_IMPL_ISUPPORTS0(GfxInitialization)
-}
-
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
 
 static nsresult
 nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
 {
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
@@ -44,45 +30,34 @@ nsScriptableRegionConstructor(nsISupport
   if (aOuter) {
     return NS_ERROR_NO_AGGREGATION;
   }
 
   nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion();
   return scriptableRgn->QueryInterface(aIID, aResult);
 }
 
-NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
-
 NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
-NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID);
 
 static const mozilla::Module::CIDEntry kThebesCIDs[] = {
     { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor },
     { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor },
-    { &kNS_GFX_INITIALIZATION_CID, false, nullptr, GfxInitializationConstructor },
     { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
     { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
     { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
-    { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
     { nullptr }
 };
 
-static void
-nsThebesGfxModuleDtor()
-{
-    gfxPlatform::Shutdown();
-}
-
 static const mozilla::Module kThebesModule = {
     mozilla::Module::kVersion,
     kThebesCIDs,
     kThebesContracts,
     nullptr,
     nullptr,
     nullptr,
-    nsThebesGfxModuleDtor
+    nullptr
 };
 
 NSMODULE_DEFN(nsGfxModule) = &kThebesModule;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -416,21 +416,16 @@ gfxPlatform::Init()
     // Texture pool init
     mozilla::gl::TexturePoolOGL::Init();
 #endif
 
 #ifdef MOZ_WIDGET_GONK
     mozilla::layers::InitGralloc();
 #endif
 
-    // Force registration of the gfx component, thus arranging for
-    // ::Shutdown to be called.
-    nsCOMPtr<nsISupports> forceReg
-        = do_CreateInstance("@mozilla.org/gfx/init;1");
-
     Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr);
 
     CreateCMSOutputProfile();
 
     // Listen to memory pressure event so we can purge DrawTarget caches
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         gPlatform->mMemoryPressureObserver = new MemoryPressureObserver();
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -65,16 +65,17 @@
 
 // view stuff
 #include "nsContentCreatorFunctions.h"
 
 // DOM includes
 #include "nsDOMBlobBuilder.h"
 #include "nsDOMFileReader.h"
 
+#include "gfxPlatform.h"
 #include "nsFormData.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsHostObjectURI.h"
 #include "nsGlobalWindowCommands.h"
 #include "nsIControllerCommandTable.h"
 #include "nsJSProtocolHandler.h"
 #include "nsScriptNameSpaceManager.h"
 #include "nsIControllerContext.h"
@@ -1245,16 +1246,20 @@ static const mozilla::Module::CategoryEn
 
 static void
 LayoutModuleDtor()
 {
   Shutdown();
   nsContentUtils::XPCOMShutdown();
   nsScriptSecurityManager::Shutdown();
   xpcModuleDtor();
+
+  // Layout depends heavily on gfx, so we want to make sure that gfx is shut
+  // down after all the layout cleanup runs.
+  gfxPlatform::Shutdown();
 }
 
 static const mozilla::Module kLayoutModule = {
   mozilla::Module::kVersion,
   kLayoutCIDs,
   kLayoutContracts,
   kLayoutCategories,
   nullptr,