Bug 1546298 - Set CompositorManagerParent::sInstance in GPU process r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Tue, 23 Apr 2019 12:21:56 +0000
changeset 470479 faab5ee080b68acb0eff49bf0a9f3db10ad44a8d
parent 470478 f987a04773cf19f1f8acf0d87c36dc45e44f586c
child 470480 b2a8685b55e1904694913e75c89151056a6d3508
push id35906
push useraciure@mozilla.com
push dateTue, 23 Apr 2019 22:14:56 +0000
treeherdermozilla-central@0ce3633f8b80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1546298
milestone68.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 1546298 - Set CompositorManagerParent::sInstance in GPU process r=nical CompositorManagerParent::sInstance is not set in GPU process. It is necessary to send NotifyWebRenderError message. Differential Revision: https://phabricator.services.mozilla.com/D28452
gfx/ipc/GPUParent.cpp
gfx/ipc/GPUProcessManager.cpp
gfx/layers/ipc/CompositorManagerChild.cpp
gfx/layers/ipc/CompositorManagerParent.cpp
gfx/layers/ipc/CompositorManagerParent.h
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -261,17 +261,17 @@ mozilla::ipc::IPCResult GPUParent::RecvI
 
   Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_INITIALIZATION_TIME_MS,
                                  mLaunchTime);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult GPUParent::RecvInitCompositorManager(
     Endpoint<PCompositorManagerParent>&& aEndpoint) {
-  CompositorManagerParent::Create(std::move(aEndpoint));
+  CompositorManagerParent::Create(std::move(aEndpoint), /* aIsRoot */ true);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult GPUParent::RecvInitVsyncBridge(
     Endpoint<PVsyncBridgeParent>&& aVsyncEndpoint) {
   mVsyncBridge = VsyncBridgeParent::Start(std::move(aVsyncEndpoint));
   return IPC_OK();
 }
@@ -372,17 +372,17 @@ mozilla::ipc::IPCResult GPUParent::RecvS
   }
 #endif
   RecvGetDeviceStatus(aOut);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult GPUParent::RecvNewContentCompositorManager(
     Endpoint<PCompositorManagerParent>&& aEndpoint) {
-  CompositorManagerParent::Create(std::move(aEndpoint));
+  CompositorManagerParent::Create(std::move(aEndpoint), /* aIsRoot */ false);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult GPUParent::RecvNewContentImageBridge(
     Endpoint<PImageBridgeParent>&& aEndpoint) {
   if (!ImageBridgeParent::CreateForContent(std::move(aEndpoint))) {
     return IPC_FAIL_NO_REASON(this);
   }
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -799,17 +799,18 @@ bool GPUProcessManager::CreateContentCom
   if (NS_FAILED(rv)) {
     gfxCriticalNote << "Could not create content compositor manager: "
                     << hexa(int(rv));
     return false;
   }
 
   if (mGPUChild) {
     mGPUChild->SendNewContentCompositorManager(std::move(parentPipe));
-  } else if (!CompositorManagerParent::Create(std::move(parentPipe))) {
+  } else if (!CompositorManagerParent::Create(std::move(parentPipe),
+                                              /* aIsRoot */ false)) {
     return false;
   }
 
   *aOutEndpoint = std::move(childPipe);
   return true;
 }
 
 bool GPUProcessManager::CreateContentImageBridge(
--- a/gfx/layers/ipc/CompositorManagerChild.cpp
+++ b/gfx/layers/ipc/CompositorManagerChild.cpp
@@ -44,17 +44,17 @@ void CompositorManagerChild::InitSamePro
       CompositorManagerParent::CreateSameProcess();
   RefPtr<CompositorManagerChild> child =
       new CompositorManagerChild(parent, aProcessToken, aNamespace);
   if (NS_WARN_IF(!child->CanSend())) {
     MOZ_DIAGNOSTIC_ASSERT(false, "Failed to open same process protocol");
     return;
   }
 
-  parent->BindComplete();
+  parent->BindComplete(/* aIsRoot */ true);
   sInstance = child.forget();
 }
 
 /* static */
 bool CompositorManagerChild::Init(Endpoint<PCompositorManagerChild>&& aEndpoint,
                                   uint32_t aNamespace,
                                   uint64_t aProcessToken /* = 0 */) {
   MOZ_ASSERT(NS_IsMainThread());
--- a/gfx/layers/ipc/CompositorManagerParent.cpp
+++ b/gfx/layers/ipc/CompositorManagerParent.cpp
@@ -46,33 +46,33 @@ CompositorManagerParent::CreateSameProce
   // on the main thread and complete before we return the manager handles.
   RefPtr<CompositorManagerParent> parent = new CompositorManagerParent();
   parent->SetOtherProcessId(base::GetCurrentProcId());
   return parent.forget();
 }
 
 /* static */
 bool CompositorManagerParent::Create(
-    Endpoint<PCompositorManagerParent>&& aEndpoint) {
+    Endpoint<PCompositorManagerParent>&& aEndpoint, bool aIsRoot) {
   MOZ_ASSERT(NS_IsMainThread());
 
   // We are creating a manager for the another process, inside the GPU process
   // (or UI process if it subsumbed the GPU process).
   MOZ_ASSERT(aEndpoint.OtherPid() != base::GetCurrentProcId());
 
   if (!CompositorThreadHolder::IsActive()) {
     return false;
   }
 
   RefPtr<CompositorManagerParent> bridge = new CompositorManagerParent();
 
   RefPtr<Runnable> runnable =
-      NewRunnableMethod<Endpoint<PCompositorManagerParent>&&>(
+      NewRunnableMethod<Endpoint<PCompositorManagerParent>&&, bool>(
           "CompositorManagerParent::Bind", bridge,
-          &CompositorManagerParent::Bind, std::move(aEndpoint));
+          &CompositorManagerParent::Bind, std::move(aEndpoint), aIsRoot);
   CompositorThreadHolder::Loop()->PostTask(runnable.forget());
   return true;
 }
 
 /* static */
 already_AddRefed<CompositorBridgeParent>
 CompositorManagerParent::CreateSameProcessWidgetCompositorBridge(
     CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
@@ -114,35 +114,35 @@ CompositorManagerParent::CreateSameProce
 }
 
 CompositorManagerParent::CompositorManagerParent()
     : mCompositorThreadHolder(CompositorThreadHolder::GetSingleton()) {}
 
 CompositorManagerParent::~CompositorManagerParent() {}
 
 void CompositorManagerParent::Bind(
-    Endpoint<PCompositorManagerParent>&& aEndpoint) {
+    Endpoint<PCompositorManagerParent>&& aEndpoint, bool aIsRoot) {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   if (NS_WARN_IF(!aEndpoint.Bind(this))) {
     return;
   }
 
-  BindComplete();
+  BindComplete(aIsRoot);
 }
 
-void CompositorManagerParent::BindComplete() {
+void CompositorManagerParent::BindComplete(bool aIsRoot) {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() ||
              NS_IsMainThread());
 
   // Add the IPDL reference to ourself, so we can't get freed until IPDL is
   // done with us.
   AddRef();
 
   StaticMutexAutoLock lock(sMutex);
-  if (OtherPid() == base::GetCurrentProcId()) {
+  if (aIsRoot) {
     sInstance = this;
   }
 
 #ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
   if (!sActiveActors) {
     sActiveActors = new nsTArray<CompositorManagerParent*>();
   }
   sActiveActors->AppendElement(this);
--- a/gfx/layers/ipc/CompositorManagerParent.h
+++ b/gfx/layers/ipc/CompositorManagerParent.h
@@ -25,17 +25,18 @@ class CompositorThreadHolder;
 #  define COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
 #endif
 
 class CompositorManagerParent final : public PCompositorManagerParent {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerParent)
 
  public:
   static already_AddRefed<CompositorManagerParent> CreateSameProcess();
-  static bool Create(Endpoint<PCompositorManagerParent>&& aEndpoint);
+  static bool Create(Endpoint<PCompositorManagerParent>&& aEndpoint,
+                     bool aIsRoot);
   static void Shutdown();
 
   static already_AddRefed<CompositorBridgeParent>
   CreateSameProcessWidgetCompositorBridge(CSSToLayoutDeviceScale aScale,
                                           const CompositorOptions& aOptions,
                                           bool aUseExternalSurfaceSize,
                                           const gfx::IntSize& aSurfaceSize);
 
@@ -45,17 +46,17 @@ class CompositorManagerParent final : pu
       const wr::ExternalImageId& aId);
   mozilla::ipc::IPCResult RecvReportSharedSurfacesMemory(
       ReportSharedSurfacesMemoryResolver&&);
 
   mozilla::ipc::IPCResult RecvNotifyMemoryPressure();
 
   mozilla::ipc::IPCResult RecvReportMemory(ReportMemoryResolver&&);
 
-  void BindComplete();
+  void BindComplete(bool aIsRoot);
   void ActorDestroy(ActorDestroyReason aReason) override;
 
   bool DeallocPCompositorBridgeParent(PCompositorBridgeParent* aActor);
   PCompositorBridgeParent* AllocPCompositorBridgeParent(
       const CompositorBridgeOptions& aOpt);
 
   static void NotifyWebRenderError(wr::WebRenderError aError);
 
@@ -66,17 +67,17 @@ class CompositorManagerParent final : pu
 #ifdef COMPOSITOR_MANAGER_PARENT_EXPLICIT_SHUTDOWN
   static StaticAutoPtr<nsTArray<CompositorManagerParent*>> sActiveActors;
   static void ShutdownInternal();
 #endif
 
   CompositorManagerParent();
   virtual ~CompositorManagerParent();
 
-  void Bind(Endpoint<PCompositorManagerParent>&& aEndpoint);
+  void Bind(Endpoint<PCompositorManagerParent>&& aEndpoint, bool aIsRoot);
 
   void DeallocPCompositorManagerParent() override;
 
   void DeferredDestroy();
 
   RefPtr<CompositorThreadHolder> mCompositorThreadHolder;
 
   AutoTArray<RefPtr<CompositorBridgeParent>, 1> mPendingCompositorBridges;