Bug 1561178 - Initialize gfxVars in the RDD process. r=jya
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 28 Jun 2019 07:08:43 +0000
changeset 543330 29d310d368efef7ae997f69dc979e7fcb6f6bfa9
parent 543329 ff918c1013b8d543c34fa54b7f56eaf2baa41112
child 543331 bde71705988f6599e8411e7ee9af68a3fab9c161
push id2131
push userffxbld-merge
push dateMon, 26 Aug 2019 18:30:20 +0000
treeherdermozilla-release@b19ffb3ca153 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1561178
milestone69.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 1561178 - Initialize gfxVars in the RDD process. r=jya Differential Revision: https://phabricator.services.mozilla.com/D36001
dom/media/ipc/PRDD.ipdl
dom/media/ipc/RDDChild.cpp
dom/media/ipc/RDDChild.h
dom/media/ipc/RDDParent.cpp
dom/media/ipc/RDDParent.h
--- a/dom/media/ipc/PRDD.ipdl
+++ b/dom/media/ipc/PRDD.ipdl
@@ -1,13 +1,14 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+include GraphicsMessages;
 include MemoryReportTypes;
 include PrefsTypes;
 
 include protocol PProfiler;
 include protocol PRemoteDecoderManager;
 include protocol PVideoBridge;
 
 using mozilla::dom::NativeThreadId from "mozilla/dom/TabMessageUtils.h";
@@ -17,30 +18,34 @@ namespace mozilla {
 // This protocol allows the UI process to talk to the RDD
 // (RemoteDataDecoder) process. There is one instance of this protocol,
 // with the RDDParent living on the main thread of the RDD process and
 // the RDDChild living on the main thread of the UI process.
 protocol PRDD
 {
 parent:
 
-  async Init(FileDescriptor? sandboxBroker, bool startMacSandbox);
+  async Init(GfxVarUpdate[] vars,
+             FileDescriptor? sandboxBroker,
+             bool startMacSandbox);
 
   async InitProfiler(Endpoint<PProfilerChild> endpoint);
 
   async NewContentRemoteDecoderManager(
             Endpoint<PRemoteDecoderManagerParent> endpoint);
 
   async RequestMemoryReport(uint32_t generation,
                             bool anonymize,
                             bool minimizeMemoryUsage,
                             FileDescriptor? DMDFile);
 
   async PreferenceUpdate(Pref pref);
 
+  async UpdateVar(GfxVarUpdate var);
+
   async CreateVideoBridgeToParentProcess(Endpoint<PVideoBridgeChild> endpoint);
 
 child:
   // args TBD, sent when init complete. Occurs once, after Init().
   async InitComplete();
 
   async InitCrashReporter(Shmem shmem, NativeThreadId threadId);
 
--- a/dom/media/ipc/RDDChild.cpp
+++ b/dom/media/ipc/RDDChild.cpp
@@ -2,30 +2,32 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #include "RDDChild.h"
 
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/ipc/CrashReporterHost.h"
+#include "mozilla/gfx/gfxVars.h"
 
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
 #  include "mozilla/SandboxBroker.h"
 #  include "mozilla/SandboxBrokerPolicyFactory.h"
 #endif
 
 #ifdef MOZ_GECKO_PROFILER
 #  include "ProfilerParent.h"
 #endif
 #include "RDDProcessHost.h"
 
 namespace mozilla {
 
 using namespace layers;
+using namespace gfx;
 
 RDDChild::RDDChild(RDDProcessHost* aHost) : mHost(aHost), mRDDReady(false) {
   MOZ_COUNT_CTOR(RDDChild);
 }
 
 RDDChild::~RDDChild() { MOZ_COUNT_DTOR(RDDChild); }
 
 bool RDDChild::Init(bool aStartMacSandbox) {
@@ -41,22 +43,26 @@ bool RDDChild::Init(bool aStartMacSandbo
     // exhaustion, but we can at least try to recover.
     if (NS_WARN_IF(mSandboxBroker == nullptr)) {
       return false;
     }
     MOZ_ASSERT(brokerFd.ref().IsValid());
   }
 #endif  // XP_LINUX && MOZ_SANDBOX
 
-  SendInit(brokerFd, aStartMacSandbox);
+  nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
+
+  SendInit(updates, brokerFd, aStartMacSandbox);
 
 #ifdef MOZ_GECKO_PROFILER
   Unused << SendInitProfiler(ProfilerParent::CreateForProcess(OtherPid()));
 #endif
 
+  gfxVars::AddReceiver(this);
+
   return true;
 }
 
 bool RDDChild::EnsureRDDReady() {
   if (mRDDReady) {
     return true;
   }
 
@@ -87,16 +93,18 @@ bool RDDChild::SendRequestMemoryReport(c
                                        const bool& aMinimizeMemoryUsage,
                                        const Maybe<FileDescriptor>& aDMDFile) {
   mMemoryReportRequest = MakeUnique<MemoryReportRequestHost>(aGeneration);
   Unused << PRDDChild::SendRequestMemoryReport(aGeneration, aAnonymize,
                                                aMinimizeMemoryUsage, aDMDFile);
   return true;
 }
 
+void RDDChild::OnVarChanged(const GfxVarUpdate& aVar) { SendUpdateVar(aVar); }
+
 mozilla::ipc::IPCResult RDDChild::RecvAddMemoryReport(
     const MemoryReport& aReport) {
   if (mMemoryReportRequest) {
     mMemoryReportRequest->RecvReport(aReport);
   }
   return IPC_OK();
 }
 
@@ -112,16 +120,17 @@ mozilla::ipc::IPCResult RDDChild::RecvFi
 void RDDChild::ActorDestroy(ActorDestroyReason aWhy) {
   if (aWhy == AbnormalShutdown) {
     if (mCrashReporter) {
       mCrashReporter->GenerateCrashReport(OtherPid());
       mCrashReporter = nullptr;
     }
   }
 
+  gfxVars::RemoveReceiver(this);
   mHost->OnChannelClosed();
 }
 
 class DeferredDeleteRDDChild : public Runnable {
  public:
   explicit DeferredDeleteRDDChild(UniquePtr<RDDChild>&& aChild)
       : Runnable("gfx::DeferredDeleteRDDChild"), mChild(std::move(aChild)) {}
 
--- a/dom/media/ipc/RDDChild.h
+++ b/dom/media/ipc/RDDChild.h
@@ -4,43 +4,46 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 #ifndef _include_dom_media_ipc_RDDChild_h_
 #define _include_dom_media_ipc_RDDChild_h_
 #include "mozilla/PRDDChild.h"
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
+#include "mozilla/gfx/gfxVarReceiver.h"
 
 namespace mozilla {
 
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
 class SandboxBroker;
 #endif
 
 namespace ipc {
 class CrashReporterHost;
 }  // namespace ipc
 namespace dom {
 class MemoryReportRequestHost;
 }  // namespace dom
 
 class RDDProcessHost;
 
-class RDDChild final : public PRDDChild {
+class RDDChild final : public PRDDChild, public gfx::gfxVarReceiver {
   typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
 
  public:
   explicit RDDChild(RDDProcessHost* aHost);
   ~RDDChild();
 
   bool Init(bool aStartMacSandbox);
 
   bool EnsureRDDReady();
 
+  void OnVarChanged(const GfxVarUpdate& aVar) override;
+
   // PRDDChild overrides.
   mozilla::ipc::IPCResult RecvInitComplete();
   mozilla::ipc::IPCResult RecvInitCrashReporter(
       Shmem&& shmem, const NativeThreadId& aThreadId);
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
   mozilla::ipc::IPCResult RecvAddMemoryReport(const MemoryReport& aReport);
--- a/dom/media/ipc/RDDParent.cpp
+++ b/dom/media/ipc/RDDParent.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/Assertions.h"
 #include "mozilla/HangDetails.h"
 #include "mozilla/RemoteDecoderManagerChild.h"
 #include "mozilla/RemoteDecoderManagerParent.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/MemoryReportRequest.h"
 #include "mozilla/ipc/CrashReporterClient.h"
 #include "mozilla/ipc/ProcessChild.h"
+#include "mozilla/gfx/gfxVars.h"
 
 #if defined(XP_LINUX) && defined(MOZ_SANDBOX)
 #  include "mozilla/Sandbox.h"
 #endif
 
 #ifdef MOZ_GECKO_PROFILER
 #  include "ChildProfilerController.h"
 #endif
@@ -36,16 +37,17 @@
 
 #include "nsDebugImpl.h"
 #include "nsThreadManager.h"
 #include "ProcessUtils.h"
 
 namespace mozilla {
 
 using namespace ipc;
+using namespace gfx;
 
 static RDDParent* sRDDParent;
 
 RDDParent::RDDParent() : mLaunchTime(TimeStamp::Now()) { sRDDParent = this; }
 
 RDDParent::~RDDParent() { sRDDParent = nullptr; }
 
 /* static */
@@ -78,16 +80,18 @@ bool RDDParent::Init(base::ProcessId aPa
 
   // Init crash reporter support.
   CrashReporterClient::InitSingleton(this);
 
   if (NS_FAILED(NS_InitMinimalXPCOM())) {
     return false;
   }
 
+  gfxVars::Initialize();
+
   mozilla::ipc::SetThisProcessName("RDD Process");
   return true;
 }
 
 #if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
 extern "C" {
 CGError CGSSetDenyWindowServerConnections(bool);
 void CGSShutdownServerConnections();
@@ -110,18 +114,24 @@ static void StartRDDMacSandbox() {
   if (!rv) {
     NS_WARNING(err.c_str());
     MOZ_CRASH("mozilla::StartMacSandbox failed");
   }
 }
 #endif
 
 mozilla::ipc::IPCResult RDDParent::RecvInit(
-    const Maybe<FileDescriptor>& aBrokerFd, bool aStartMacSandbox) {
+    nsTArray<GfxVarUpdate>&& vars, const Maybe<FileDescriptor>& aBrokerFd,
+    bool aStartMacSandbox) {
   Unused << SendInitComplete();
+
+  for (const auto& var : vars) {
+    gfxVars::ApplyUpdate(var);
+  }
+
 #if defined(MOZ_SANDBOX)
 #  if defined(XP_MACOSX)
   // Close all current connections to the WindowServer. This ensures that the
   // Activity Monitor will not label the content process as "Not responding"
   // because it's not running a native event loop. See bug 1384336.
   CGSShutdownServerConnections();
 
   if (aStartMacSandbox) {
@@ -138,16 +148,21 @@ mozilla::ipc::IPCResult RDDParent::RecvI
   }
   SetRemoteDataDecoderSandbox(fd);
 #  endif  // XP_MACOSX/XP_LINUX
 #endif    // MOZ_SANDBOX
 
   return IPC_OK();
 }
 
+IPCResult RDDParent::RecvUpdateVar(const GfxVarUpdate& aUpdate) {
+  gfxVars::ApplyUpdate(aUpdate);
+  return IPC_OK();
+}
+
 mozilla::ipc::IPCResult RDDParent::RecvInitProfiler(
     Endpoint<PProfilerChild>&& aEndpoint) {
 #ifdef MOZ_GECKO_PROFILER
   mProfilerController = ChildProfilerController::Create(std::move(aEndpoint));
 #endif
   return IPC_OK();
 }
 
@@ -205,13 +220,14 @@ void RDDParent::ActorDestroy(ActorDestro
   if (mProfilerController) {
     mProfilerController->Shutdown();
     mProfilerController = nullptr;
   }
 #endif
 
   RemoteDecoderManagerParent::ShutdownVideoBridge();
 
+  gfxVars::Shutdown();
   CrashReporterClient::DestroySingleton();
   XRE_ShutdownChildProcess();
 }
 
 }  // namespace mozilla
--- a/dom/media/ipc/RDDParent.h
+++ b/dom/media/ipc/RDDParent.h
@@ -19,30 +19,32 @@ class RDDParent final : public PRDDParen
   RDDParent();
   ~RDDParent();
 
   static RDDParent* GetSingleton();
 
   bool Init(base::ProcessId aParentPid, const char* aParentBuildID,
             MessageLoop* aIOLoop, IPC::Channel* aChannel);
 
-  mozilla::ipc::IPCResult RecvInit(const Maybe<ipc::FileDescriptor>& aBrokerFd,
+  mozilla::ipc::IPCResult RecvInit(nsTArray<GfxVarUpdate>&& vars,
+                                   const Maybe<ipc::FileDescriptor>& aBrokerFd,
                                    bool aStartMacSandbox);
   mozilla::ipc::IPCResult RecvInitProfiler(
       Endpoint<PProfilerChild>&& aEndpoint);
 
   mozilla::ipc::IPCResult RecvNewContentRemoteDecoderManager(
       Endpoint<PRemoteDecoderManagerParent>&& aEndpoint);
   mozilla::ipc::IPCResult RecvCreateVideoBridgeToParentProcess(
       Endpoint<PVideoBridgeChild>&& aEndpoint);
   mozilla::ipc::IPCResult RecvRequestMemoryReport(
       const uint32_t& generation, const bool& anonymize,
       const bool& minimizeMemoryUsage,
       const Maybe<ipc::FileDescriptor>& DMDFile);
   mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& pref);
+  mozilla::ipc::IPCResult RecvUpdateVar(const GfxVarUpdate& pref);
 
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
  private:
   const TimeStamp mLaunchTime;
 #ifdef MOZ_GECKO_PROFILER
   RefPtr<ChildProfilerController> mProfilerController;
 #endif