Bug 1337062 - Transfer initial gfxVars with SendSetXPCOMProcessAttributes - r=dvander
☠☠ backed out by f77f3057b8ee ☠ ☠
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 11 Apr 2017 15:36:56 +1200
changeset 353016 2d7ef036a01fb38bc37eed59390af4f79f149ba4
parent 353015 afef2f99d59b7013e449ad485cb801439c20c298
child 353017 419b0dc9e1a69df64878c608869205efb547439e
push id89185
push userkwierso@gmail.com
push dateFri, 14 Apr 2017 00:33:57 +0000
treeherdermozilla-inbound@945c45613592 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1337062
milestone55.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 1337062 - Transfer initial gfxVars with SendSetXPCOMProcessAttributes - r=dvander MozReview-Commit-ID: EUnwXkDwBTZ
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/PContent.ipdl
gfx/config/gfxVars.cpp
gfx/config/gfxVars.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -514,16 +514,17 @@ NS_INTERFACE_MAP_END
 
 
 mozilla::ipc::IPCResult
 ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
                                             const StructuredCloneData& aInitialData,
                                             nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache)
 {
   mLookAndFeelCache = aLookAndFeelIntCache;
+  gfx::gfxVars::Initialize(&aXPCOMInit.gfxNonDefaultVarUpdates());
   InitXPCOM(aXPCOMInit, aInitialData);
   InitGraphicsDeviceData(aXPCOMInit.contentDeviceData());
   return IPC_OK();
 }
 
 bool
 ContentChild::Init(MessageLoop* aIOLoop,
                    base::ProcessId aParentPid,
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2217,17 +2217,22 @@ ContentParent::InitInternal(ProcessPrior
   // send the file URL instead.
   StyleSheet* ucs = nsLayoutStylesheetCache::For(StyleBackendType::Gecko)->UserContentSheet();
   if (ucs) {
     SerializeURI(ucs->GetSheetURI(), xpcomInit.userContentSheetURL());
   } else {
     SerializeURI(nullptr, xpcomInit.userContentSheetURL());
   }
 
+  // 1. Build ContentDeviceData first, as it may affect some gfxVars.
   gfxPlatform::GetPlatform()->BuildContentDeviceData(&xpcomInit.contentDeviceData());
+  // 2. Gather non-default gfxVars.
+  xpcomInit.gfxNonDefaultVarUpdates() = gfxVars::FetchNonDefaultVars();
+  // 3. Start listening for gfxVars updates, to notify content process later on.
+  gfxVars::AddReceiver(this);
 
   nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
   if (gfxInfo) {
     for (int32_t i = 1; i <= nsIGfxInfo::FEATURE_MAX_VALUE; ++i) {
       int32_t status = 0;
       nsAutoCString failureId;
       gfxInfo->GetFeatureStatus(i, failureId, &status);
       dom::GfxInfoFeatureStatus gfxFeatureStatus;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -260,16 +260,17 @@ struct XPCOMInitData
     bool haveBidiKeyboards;
     nsString[] dictionaries;
     ClipboardCapabilities clipboardCaps;
     DomainPolicyClone domainPolicy;
     /* used on MacOSX only */
     FontFamilyListEntry[] fontFamilies;
     OptionalURIParams userContentSheetURL;
     PrefSetting[] prefs;
+    GfxVarUpdate[] gfxNonDefaultVarUpdates;
     ContentDeviceData contentDeviceData;
     GfxInfoFeatureStatus[] gfxFeatureStatus;
     DataStorageEntry[] dataStorage;
 };
 
 /**
  * The PContent protocol is a top-level protocol between the UI process
  * and a content process. There is exactly one PContentParent/PContentChild pair
--- a/gfx/config/gfxVars.cpp
+++ b/gfx/config/gfxVars.cpp
@@ -10,35 +10,41 @@
 
 namespace mozilla {
 namespace gfx {
 
 StaticAutoPtr<gfxVars> gfxVars::sInstance;
 StaticAutoPtr<nsTArray<gfxVars::VarBase*>> gfxVars::sVarList;
 
 void
-gfxVars::Initialize()
+gfxVars::Initialize(const nsTArray<GfxVarUpdate>* aInitUpdates /* = nullptr */)
 {
   if (sInstance) {
+    // We expect aInitUpdates to be provided before any other gfxVars operation.
+    MOZ_RELEASE_ASSERT(!aInitUpdates, "aInitUpdates should not be provided after any gfxVars operation");
     return;
   }
 
   // sVarList must be initialized first since it's used in the constructor for
   // sInstance.
   sVarList = new nsTArray<gfxVars::VarBase*>();
   sInstance = new gfxVars;
 
-  // Like Preferences, we want content to synchronously get initial data on
-  // init. Note the GPU process is not handled here - it cannot send sync
+  // Note the GPU process is not handled here - it cannot send sync
   // messages, so instead the initial data is pushed down.
   if (XRE_IsContentProcess()) {
-    InfallibleTArray<GfxVarUpdate> vars;
-    dom::ContentChild::GetSingleton()->SendGetGfxVars(&vars);
-    for (const auto& var : vars) {
-      ApplyUpdate(var);
+    MOZ_RELEASE_ASSERT(aInitUpdates, "aInitUpdates must be provided in content process");
+    InfallibleTArray<GfxVarUpdate> initUpdates;
+    if (!aInitUpdates) {
+      // No provided initial updates, sync-request them from parent.
+      dom::ContentChild::GetSingleton()->SendGetGfxVars(&initUpdates);
+      aInitUpdates = &initUpdates;
+    }
+    for (const auto& varUpdate : *aInitUpdates) {
+      ApplyUpdate(varUpdate);
     }
   }
 }
 
 gfxVars::gfxVars()
 {
 }
 
--- a/gfx/config/gfxVars.h
+++ b/gfx/config/gfxVars.h
@@ -52,17 +52,17 @@ class gfxVarReceiver;
 //    void SetCxxName(const DataType& aValue);
 //
 // Note that the setter may only be called in the UI process; a gfxVar must be
 // a variable that is determined in the UI process and pushed to child
 // processes.
 class gfxVars final
 {
 public:
-  static void Initialize();
+  static void Initialize(const nsTArray<GfxVarUpdate>* aInitUpdates = nullptr);
   static void Shutdown();
 
   static void ApplyUpdate(const GfxVarUpdate& aUpdate);
   static void AddReceiver(gfxVarReceiver* aReceiver);
   static void RemoveReceiver(gfxVarReceiver* aReceiver);
 
   // Return a list of updates for all variables with non-default values.
   static nsTArray<GfxVarUpdate> FetchNonDefaultVars();