Bug 1398993 - Disable stylo in e10s parent process. r=xidorn
authorCameron McCormack <cam@mcc.id.au>
Wed, 13 Sep 2017 17:13:11 +0800
changeset 430293 a4bfe93c85a455f518c5dca6df42c0763747a5ec
parent 430292 7ca5a17fbf90ce206dffff30a4a0d8db57301f8d
child 430294 9517eea4a1a5955618fc79d039f9f0282b7185ca
child 430335 1fb3bbbaa565dc619ace333a8b2028367c9012ad
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersxidorn
bugs1398993
milestone57.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 1398993 - Disable stylo in e10s parent process. r=xidorn nsLayoutStatics::Initialize is sometimes too early to know whether a process is an e10s parent process, or a non-e10s main process, because some prefs get loaded later on. So we unconditionally initialize some Servo data in nsLayoutStatics::Initialize, but we still check later on whether we are really a non-e10s main process or e10s content process when deciding whether to preload Servo style sheets, choose our document backend type, etc. MozReview-Commit-ID: 93tPCvuTdzl
layout/base/nsLayoutUtils.h
layout/base/nsStyleSheetService.cpp
layout/build/nsLayoutStatics.cpp
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2479,22 +2479,29 @@ public:
     return sTextCombineUprightDigitsEnabled;
   }
 
   // Stylo (the Servo backend for Gecko's style system) is generally enabled
   // or disabled at compile-time. However, we provide the additional capability
   // to disable it dynamically in stylo-enabled builds via a pref.
   static bool StyloEnabled() {
 #ifdef MOZ_STYLO
-    return sStyloEnabled;
+    return sStyloEnabled && StyloSupportedInCurrentProcess();
 #else
     return false;
 #endif
   }
 
+  // Whether Stylo should be allowed to be enabled in this process.  This
+  // returns true for content processes and the non-e10s parent process.
+  static bool StyloSupportedInCurrentProcess() {
+     return XRE_IsContentProcess() ||
+            (XRE_IsParentProcess() && !XRE_IsE10sParentProcess());
+  }
+
   static bool StyleAttrWithXMLBaseDisabled() {
     return sStyleAttrWithXMLBaseDisabled;
   }
 
   static uint32_t IdlePeriodDeadlineLimit() {
     return sIdlePeriodDeadlineLimit;
   }
 
--- a/layout/base/nsStyleSheetService.cpp
+++ b/layout/base/nsStyleSheetService.cpp
@@ -253,19 +253,21 @@ nsStyleSheetService::LoadAndRegisterShee
   RefPtr<StyleSheet> geckoSheet;
   RefPtr<StyleSheet> servoSheet;
 
   rv = LoadSheet(aSheetURI, parsingMode, StyleBackendType::Gecko, &geckoSheet);
   NS_ENSURE_SUCCESS(rv, rv);
   MOZ_ASSERT(geckoSheet);
 
 #ifdef MOZ_STYLO
-  rv = LoadSheet(aSheetURI, parsingMode, StyleBackendType::Servo, &servoSheet);
-  NS_ENSURE_SUCCESS(rv, rv);
-  MOZ_ASSERT(servoSheet);
+  if (nsLayoutUtils::StyloSupportedInCurrentProcess()) {
+    rv = LoadSheet(aSheetURI, parsingMode, StyleBackendType::Servo, &servoSheet);
+    NS_ENSURE_SUCCESS(rv, rv);
+    MOZ_ASSERT(servoSheet);
+  }
 #endif
 
   mGeckoSheets[aSheetType].AppendElement(geckoSheet);
   mServoSheets[aSheetType].AppendElement(servoSheet);
 
   return NS_OK;
 }
 
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -296,17 +296,19 @@ nsLayoutStatics::Initialize()
 
   MediaDecoder::InitStatics();
 
   PromiseDebugging::Init();
 
   mozilla::dom::WebCryptoThreadPool::Initialize();
 
 #ifdef MOZ_STYLO
-  InitializeServo();
+  if (XRE_IsParentProcess() || XRE_IsContentProcess()) {
+    InitializeServo();
+  }
 #endif
 
 #ifndef MOZ_WIDGET_ANDROID
   // On Android, we instantiate it when constructing AndroidBridge.
   MediaPrefs::GetSingleton();
 #endif
 
   // This must be initialized on the main-thread.
@@ -318,18 +320,20 @@ nsLayoutStatics::Initialize()
 
 void
 nsLayoutStatics::Shutdown()
 {
   // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
   // memory reporter manager.
 
 #ifdef MOZ_STYLO
-  ShutdownServo();
-  URLExtraData::ReleaseDummy();
+  if (XRE_IsParentProcess() || XRE_IsContentProcess()) {
+    ShutdownServo();
+    URLExtraData::ReleaseDummy();
+  }
 #endif
 
   nsMessageManagerScriptExecutor::Shutdown();
   nsFocusManager::Shutdown();
 #ifdef MOZ_XUL
   nsXULPopupManager::Shutdown();
 #endif
   StorageObserver::Shutdown();