Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
☠☠ backed out by 62cd40511419 ☠ ☠
authorvincentliu <vliu@mozilla.com>
Fri, 17 Mar 2017 09:49:13 +0800
changeset 348059 a6780188f66986608a220efc6095e93daaa9e45e
parent 348058 77b0e80d2bd3c7605682686d384b6dea62a4540e
child 348060 12ce302b8f9be8fe2b8782c0b0a85dc2919f7563
push id88142
push uservliu@mozilla.com
push dateFri, 17 Mar 2017 01:49:54 +0000
treeherdermozilla-inbound@a6780188f669 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1314543
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 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
gfx/ipc/GPUChild.cpp
gfx/ipc/GPUChild.h
gfx/ipc/GPUProcessManager.cpp
gfx/ipc/GPUProcessManager.h
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -67,29 +67,32 @@ GPUChild::Init()
 }
 
 void
 GPUChild::OnVarChanged(const GfxVarUpdate& aVar)
 {
   SendUpdateVar(aVar);
 }
 
-void
+bool
 GPUChild::EnsureGPUReady()
 {
   if (mGPUReady) {
-    return;
+    return true;
   }
 
   GPUDeviceData data;
-  SendGetDeviceStatus(&data);
+  if (!SendGetDeviceStatus(&data)) {
+    return false;
+  }
 
   gfxPlatform::GetPlatform()->ImportGPUDeviceData(data);
   Telemetry::AccumulateTimeDelta(Telemetry::GPU_PROCESS_LAUNCH_TIME_MS_2, mHost->GetLaunchTime());
   mGPUReady = true;
+  return true;
 }
 
 mozilla::ipc::IPCResult
 GPUChild::RecvInitComplete(const GPUDeviceData& aData)
 {
   // We synchronously requested GPU parameters before this arrived.
   if (mGPUReady) {
     return IPC_OK();
--- a/gfx/ipc/GPUChild.h
+++ b/gfx/ipc/GPUChild.h
@@ -29,17 +29,17 @@ class GPUChild final
   typedef mozilla::dom::MemoryReportRequestHost MemoryReportRequestHost;
 
 public:
   explicit GPUChild(GPUProcessHost* aHost);
   ~GPUChild();
 
   void Init();
 
-  void EnsureGPUReady();
+  bool EnsureGPUReady();
 
   // gfxVarReceiver overrides.
   void OnVarChanged(const GfxVarUpdate& aVar) override;
 
   // PGPUChild overrides.
   mozilla::ipc::IPCResult RecvInitComplete(const GPUDeviceData& aData) override;
   mozilla::ipc::IPCResult RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog) override;
   mozilla::ipc::IPCResult RecvInitCrashReporter(Shmem&& shmem, const NativeThreadId& aThreadId) override;
--- a/gfx/ipc/GPUProcessManager.cpp
+++ b/gfx/ipc/GPUProcessManager.cpp
@@ -158,43 +158,43 @@ GPUProcessManager::DisableGPUProcess(con
   gfxCriticalNote << aMessage;
 
   gfxPlatform::NotifyGPUProcessDisabled();
 
   DestroyProcess();
   ShutdownVsyncIOThread();
 }
 
-void
+bool
 GPUProcessManager::EnsureGPUReady()
 {
   if (mProcess && !mProcess->IsConnected()) {
     if (!mProcess->WaitForLaunch()) {
       // If this fails, we should have fired OnProcessLaunchComplete and
       // removed the process.
       MOZ_ASSERT(!mProcess && !mGPUChild);
-      return;
+      return false;
     }
   }
 
-  if (mGPUChild) {
-    mGPUChild->EnsureGPUReady();
+  if (mGPUChild && mGPUChild->EnsureGPUReady()) {
+    return true;
   }
+
+  return false;
 }
 
 void
 GPUProcessManager::EnsureImageBridgeChild()
 {
   if (ImageBridgeChild::GetSingleton()) {
     return;
   }
 
-  EnsureGPUReady();
-
-  if (!mGPUChild) {
+  if (!EnsureGPUReady()) {
     ImageBridgeChild::InitSameProcess();
     return;
   }
 
   ipc::Endpoint<PImageBridgeParent> parentPipe;
   ipc::Endpoint<PImageBridgeChild> childPipe;
   nsresult rv = PImageBridge::CreateEndpoints(
     mGPUChild->OtherPid(),
@@ -212,19 +212,17 @@ GPUProcessManager::EnsureImageBridgeChil
 
 void
 GPUProcessManager::EnsureVRManager()
 {
   if (VRManagerChild::IsCreated()) {
     return;
   }
 
-  EnsureGPUReady();
-
-  if (!mGPUChild) {
+  if (!EnsureGPUReady()) {
     VRManagerChild::InitSameProcess();
     return;
   }
 
   ipc::Endpoint<PVRManagerParent> parentPipe;
   ipc::Endpoint<PVRManagerChild> childPipe;
   nsresult rv = PVRManager::CreateEndpoints(
     mGPUChild->OtherPid(),
@@ -243,25 +241,23 @@ GPUProcessManager::EnsureVRManager()
 #if defined(MOZ_WIDGET_ANDROID)
 void
 GPUProcessManager::EnsureUiCompositorController()
 {
   if (UiCompositorControllerChild::IsInitialized()) {
     return;
   }
 
-  EnsureGPUReady();
-
   RefPtr<nsThread> uiThread;
 
   uiThread = GetAndroidUiThread();
 
   MOZ_ASSERT(uiThread);
 
-  if (!mGPUChild) {
+  if (!EnsureGPUReady()) {
     UiCompositorControllerChild::InitSameProcess(uiThread);
     return;
   }
 
   ipc::Endpoint<PUiCompositorControllerParent> parentPipe;
   ipc::Endpoint<PUiCompositorControllerChild> childPipe;
   nsresult rv = PUiCompositorController::CreateEndpoints(
     mGPUChild->OtherPid(),
@@ -541,24 +537,23 @@ GPUProcessManager::CreateTopLevelComposi
                                             LayerManager* aLayerManager,
                                             CSSToLayoutDeviceScale aScale,
                                             const CompositorOptions& aOptions,
                                             bool aUseExternalSurfaceSize,
                                             const gfx::IntSize& aSurfaceSize)
 {
   uint64_t layerTreeId = AllocateLayerTreeId();
 
-  EnsureGPUReady();
   EnsureImageBridgeChild();
   EnsureVRManager();
 #if defined(MOZ_WIDGET_ANDROID)
   EnsureUiCompositorController();
 #endif // defined(MOZ_WIDGET_ANDROID)
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     RefPtr<CompositorSession> session = CreateRemoteSession(
       aWidget,
       aLayerManager,
       layerTreeId,
       aScale,
       aOptions,
       aUseExternalSurfaceSize,
       aSurfaceSize);
@@ -677,18 +672,16 @@ GPUProcessManager::CreateContentBridges(
   CreateContentVideoDecoderManager(aOtherProcess, aOutVideoManager);
   return true;
 }
 
 bool
 GPUProcessManager::CreateContentCompositorBridge(base::ProcessId aOtherProcess,
                                                  ipc::Endpoint<PCompositorBridgeChild>* aOutEndpoint)
 {
-  EnsureGPUReady();
-
   ipc::Endpoint<PCompositorBridgeParent> parentPipe;
   ipc::Endpoint<PCompositorBridgeChild> childPipe;
 
   base::ProcessId gpuPid = mGPUChild
                            ? mGPUChild->OtherPid()
                            : base::GetCurrentProcId();
 
   nsresult rv = PCompositorBridge::CreateEndpoints(
@@ -696,17 +689,17 @@ GPUProcessManager::CreateContentComposit
     aOtherProcess,
     &parentPipe,
     &childPipe);
   if (NS_FAILED(rv)) {
     gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv));
     return false;
   }
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     mGPUChild->SendNewContentCompositorBridge(Move(parentPipe));
   } else {
     if (!CompositorBridgeParent::CreateForContent(Move(parentPipe))) {
       return false;
     }
   }
 
   *aOutEndpoint = Move(childPipe);
@@ -730,17 +723,17 @@ GPUProcessManager::CreateContentImageBri
     aOtherProcess,
     &parentPipe,
     &childPipe);
   if (NS_FAILED(rv)) {
     gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv));
     return false;
   }
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     mGPUChild->SendNewContentImageBridge(Move(parentPipe));
   } else {
     if (!ImageBridgeParent::CreateForContent(Move(parentPipe))) {
       return false;
     }
   }
 
   *aOutEndpoint = Move(childPipe);
@@ -773,33 +766,33 @@ GPUProcessManager::CreateContentVRManage
     aOtherProcess,
     &parentPipe,
     &childPipe);
   if (NS_FAILED(rv)) {
     gfxCriticalNote << "Could not create content compositor bridge: " << hexa(int(rv));
     return false;
   }
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     mGPUChild->SendNewContentVRManager(Move(parentPipe));
   } else {
     if (!VRManagerParent::CreateForContent(Move(parentPipe))) {
       return false;
     }
   }
 
   *aOutEndpoint = Move(childPipe);
   return true;
 }
 
 void
 GPUProcessManager::CreateContentVideoDecoderManager(base::ProcessId aOtherProcess,
                                                     ipc::Endpoint<dom::PVideoDecoderManagerChild>* aOutEndpoint)
 {
-  if (!mGPUChild || !MediaPrefs::PDMUseGPUDecoder()) {
+  if (!EnsureGPUReady() || !MediaPrefs::PDMUseGPUDecoder()) {
     return;
   }
 
   ipc::Endpoint<dom::PVideoDecoderManagerParent> parentPipe;
   ipc::Endpoint<dom::PVideoDecoderManagerChild> childPipe;
 
   nsresult rv = dom::PVideoDecoderManager::CreateEndpoints(
     mGPUChild->OtherPid(),
@@ -823,29 +816,29 @@ GPUProcessManager::GetAPZCTreeManagerFor
   return CompositorBridgeParent::GetAPZCTreeManager(aLayersId);
 }
 
 void
 GPUProcessManager::MapLayerTreeId(uint64_t aLayersId, base::ProcessId aOwningId)
 {
   LayerTreeOwnerTracker::Get()->Map(aLayersId, aOwningId);
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     AutoTArray<LayerTreeIdMapping, 1> mappings;
     mappings.AppendElement(LayerTreeIdMapping(aLayersId, aOwningId));
     mGPUChild->SendAddLayerTreeIdMapping(mappings);
   }
 }
 
 void
 GPUProcessManager::UnmapLayerTreeId(uint64_t aLayersId, base::ProcessId aOwningId)
 {
   LayerTreeOwnerTracker::Get()->Unmap(aLayersId, aOwningId);
 
-  if (mGPUChild) {
+  if (EnsureGPUReady()) {
     mGPUChild->SendRemoveLayerTreeIdMapping(LayerTreeIdMapping(aLayersId, aOwningId));
     return;
   }
   CompositorBridgeParent::DeallocateLayerTreeId(aLayersId);
 }
 
 bool
 GPUProcessManager::IsLayerTreeIdMapped(uint64_t aLayersId, base::ProcessId aRequestingId)
@@ -899,17 +892,17 @@ void
 GPUProcessManager::RemoveListener(GPUProcessListener* aListener)
 {
   mListeners.RemoveElement(aListener);
 }
 
 bool
 GPUProcessManager::NotifyGpuObservers(const char* aTopic)
 {
-  if (!mGPUChild) {
+  if (!EnsureGPUReady()) {
     return false;
   }
   nsCString topic(aTopic);
   mGPUChild->SendNotifyGpuObservers(topic);
   return true;
 }
 
 class GPUMemoryReporter : public MemoryReportingProcess
@@ -957,16 +950,16 @@ private:
 
 protected:
   ~GPUMemoryReporter() = default;
 };
 
 RefPtr<MemoryReportingProcess>
 GPUProcessManager::GetProcessMemoryReporter()
 {
-  if (!mGPUChild) {
+  if (!EnsureGPUReady()) {
     return nullptr;
   }
   return new GPUMemoryReporter();
 }
 
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/ipc/GPUProcessManager.h
+++ b/gfx/ipc/GPUProcessManager.h
@@ -75,17 +75,17 @@ public:
   ~GPUProcessManager();
 
   // If not using a GPU process, launch a new GPU process asynchronously.
   void LaunchGPUProcess();
 
   // Ensure that GPU-bound methods can be used. If no GPU process is being
   // used, or one is launched and ready, this function returns immediately.
   // Otherwise it blocks until the GPU process has finished launching.
-  void EnsureGPUReady();
+  bool EnsureGPUReady();
 
   RefPtr<CompositorSession> CreateTopLevelCompositor(
     nsBaseWidget* aWidget,
     LayerManager* aLayerManager,
     CSSToLayoutDeviceScale aScale,
     const CompositorOptions& aOptions,
     bool aUseExternalSurfaceSize,
     const gfx::IntSize& aSurfaceSize);