Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander

This commit is contained in:
vincentliu 2017-03-30 09:23:24 +08:00
parent bc7dc34148
commit 67a283ef9a
4 changed files with 27 additions and 31 deletions

View File

@ -80,19 +80,22 @@ 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

View File

@ -41,7 +41,7 @@ public:
void Init();
void EnsureGPUReady();
bool EnsureGPUReady();
// gfxVarReceiver overrides.
void OnVarChanged(const GfxVarUpdate& aVar) override;

View File

@ -163,7 +163,7 @@ GPUProcessManager::DisableGPUProcess(const char* aMessage)
ShutdownVsyncIOThread();
}
void
bool
GPUProcessManager::EnsureGPUReady()
{
if (mProcess && !mProcess->IsConnected()) {
@ -171,13 +171,15 @@ GPUProcessManager::EnsureGPUReady()
// 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
@ -187,9 +189,7 @@ GPUProcessManager::EnsureImageBridgeChild()
return;
}
EnsureGPUReady();
if (!mGPUChild) {
if (!EnsureGPUReady()) {
ImageBridgeChild::InitSameProcess();
return;
}
@ -217,9 +217,7 @@ GPUProcessManager::EnsureVRManager()
return;
}
EnsureGPUReady();
if (!mGPUChild) {
if (!EnsureGPUReady()) {
VRManagerChild::InitSameProcess();
return;
}
@ -248,15 +246,13 @@ GPUProcessManager::EnsureUiCompositorController()
return;
}
EnsureGPUReady();
RefPtr<nsThread> uiThread;
uiThread = GetAndroidUiThread();
MOZ_ASSERT(uiThread);
if (!mGPUChild) {
if (!EnsureGPUReady()) {
UiCompositorControllerChild::InitSameProcess(uiThread);
return;
}
@ -546,14 +542,13 @@ GPUProcessManager::CreateTopLevelCompositor(nsBaseWidget* aWidget,
{
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,
@ -682,12 +677,10 @@ bool
GPUProcessManager::CreateContentCompositorBridge(base::ProcessId aOtherProcess,
ipc::Endpoint<PCompositorBridgeChild>* aOutEndpoint)
{
EnsureGPUReady();
ipc::Endpoint<PCompositorBridgeParent> parentPipe;
ipc::Endpoint<PCompositorBridgeChild> childPipe;
base::ProcessId gpuPid = mGPUChild
base::ProcessId gpuPid = EnsureGPUReady()
? mGPUChild->OtherPid()
: base::GetCurrentProcId();
@ -701,7 +694,7 @@ GPUProcessManager::CreateContentCompositorBridge(base::ProcessId aOtherProcess,
return false;
}
if (mGPUChild) {
if (EnsureGPUReady()) {
mGPUChild->SendNewContentCompositorBridge(Move(parentPipe));
} else {
if (!CompositorBridgeParent::CreateForContent(Move(parentPipe))) {
@ -735,7 +728,7 @@ GPUProcessManager::CreateContentImageBridge(base::ProcessId aOtherProcess,
return false;
}
if (mGPUChild) {
if (EnsureGPUReady()) {
mGPUChild->SendNewContentImageBridge(Move(parentPipe));
} else {
if (!ImageBridgeParent::CreateForContent(Move(parentPipe))) {
@ -778,7 +771,7 @@ GPUProcessManager::CreateContentVRManager(base::ProcessId aOtherProcess,
return false;
}
if (mGPUChild) {
if (EnsureGPUReady()) {
mGPUChild->SendNewContentVRManager(Move(parentPipe));
} else {
if (!VRManagerParent::CreateForContent(Move(parentPipe))) {
@ -794,7 +787,7 @@ void
GPUProcessManager::CreateContentVideoDecoderManager(base::ProcessId aOtherProcess,
ipc::Endpoint<dom::PVideoDecoderManagerChild>* aOutEndpoint)
{
if (!mGPUChild || !MediaPrefs::PDMUseGPUDecoder()) {
if (!EnsureGPUReady() || !MediaPrefs::PDMUseGPUDecoder()) {
return;
}
@ -828,7 +821,7 @@ 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);
@ -840,7 +833,7 @@ GPUProcessManager::UnmapLayerTreeId(uint64_t aLayersId, base::ProcessId aOwningI
{
LayerTreeOwnerTracker::Get()->Unmap(aLayersId, aOwningId);
if (mGPUChild) {
if (EnsureGPUReady()) {
mGPUChild->SendRemoveLayerTreeIdMapping(LayerTreeIdMapping(aLayersId, aOwningId));
return;
}
@ -904,7 +897,7 @@ GPUProcessManager::RemoveListener(GPUProcessListener* aListener)
bool
GPUProcessManager::NotifyGpuObservers(const char* aTopic)
{
if (!mGPUChild) {
if (!EnsureGPUReady()) {
return false;
}
nsCString topic(aTopic);
@ -962,7 +955,7 @@ protected:
RefPtr<MemoryReportingProcess>
GPUProcessManager::GetProcessMemoryReporter()
{
if (!mGPUChild) {
if (!EnsureGPUReady()) {
return nullptr;
}
return new GPUMemoryReporter();

View File

@ -80,7 +80,7 @@ public:
// 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,