Bug 1362166 - Add a timeout to PCompositorManager & kill GPU process on timeout in release builds. r=dvander

MozReview-Commit-ID: Dln8ERrExmz
This commit is contained in:
Samael Wang 2017-06-22 17:27:05 +08:00
parent fbbe88a9b4
commit 06b5a3322e
3 changed files with 33 additions and 2 deletions

View File

@ -7,6 +7,7 @@
#include "mozilla/layers/CompositorBridgeChild.h"
#include "mozilla/layers/CompositorManagerParent.h"
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/gfx/GPUProcessManager.h"
#include "mozilla/dom/ContentChild.h" // for ContentChild
#include "mozilla/dom/TabChild.h" // for TabChild
#include "mozilla/dom/TabGroup.h" // for TabGroup
@ -161,6 +162,7 @@ CompositorManagerChild::CompositorManagerChild(CompositorManagerParent* aParent,
mCanSend = true;
AddRef();
SetReplyTimeout();
}
CompositorManagerChild::CompositorManagerChild(Endpoint<PCompositorManagerChild>&& aEndpoint,
@ -175,6 +177,7 @@ CompositorManagerChild::CompositorManagerChild(Endpoint<PCompositorManagerChild>
mCanSend = true;
AddRef();
SetReplyTimeout();
}
void
@ -243,5 +246,28 @@ CompositorManagerChild::GetSpecificMessageEventTarget(const Message& aMsg)
return do_AddRef(tabChild->TabGroup()->EventTargetFor(TaskCategory::Other));
}
void
CompositorManagerChild::SetReplyTimeout()
{
#ifndef DEBUG
// Add a timeout for release builds to kill GPU process when it hangs.
// Don't apply timeout when using web render as it tend to timeout frequently.
if (XRE_IsParentProcess() && !gfxVars::UseWebRender()) {
int32_t timeout = gfxPrefs::GPUProcessIPCReplyTimeoutMs();
SetReplyTimeoutMs(timeout);
}
#endif
}
bool
CompositorManagerChild::ShouldContinueFromReplyTimeout()
{
if (XRE_IsParentProcess()) {
gfxCriticalNote << "Killing GPU process due to IPC reply timeout";
GPUProcessManager::Get()->KillProcess();
}
return false;
}
} // namespace layers
} // namespace mozilla

View File

@ -66,6 +66,8 @@ public:
bool DeallocPCompositorBridgeChild(PCompositorBridgeChild* aActor) override;
bool ShouldContinueFromReplyTimeout() override;
private:
static StaticRefPtr<CompositorManagerChild> sInstance;
@ -90,6 +92,8 @@ private:
already_AddRefed<nsIEventTarget>
GetSpecificMessageEventTarget(const Message& aMsg) override;
void SetReplyTimeout();
bool mCanSend;
uint32_t mNamespace;
uint32_t mResourceId;

View File

@ -549,13 +549,14 @@ private:
DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false);
DECL_GFX_PREF(Live, "layers.flash-borders", FlashLayerBorders, bool, false);
DECL_GFX_PREF(Once, "layers.force-shmem-tiles", ForceShmemTiles, bool, false);
DECL_GFX_PREF(Once, "layers.gpu-process.allow-software", GPUProcessAllowSoftware, bool, false);
DECL_GFX_PREF(Once, "layers.gpu-process.enabled", GPUProcessEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.gpu-process.force-enabled", GPUProcessForceEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.gpu-process.startup_timeout_ms", GPUProcessTimeoutMs, int32_t, 5000);
DECL_GFX_PREF(Once, "layers.gpu-process.ipc_reply_timeout_ms", GPUProcessIPCReplyTimeoutMs, int32_t, 10000);
DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts", GPUProcessMaxRestarts, int32_t, 1);
DECL_GFX_PREF(Once, "layers.gpu-process.allow-software", GPUProcessAllowSoftware, bool, false);
// Note: This pref will only be used if it is less than layers.gpu-process.max_restarts.
DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts_with_decoder", GPUProcessMaxRestartsWithDecoder, int32_t, 0);
DECL_GFX_PREF(Once, "layers.gpu-process.startup_timeout_ms", GPUProcessTimeoutMs, int32_t, 5000);
DECL_GFX_PREF(Live, "layers.low-precision-buffer", UseLowPrecisionBuffer, bool, false);
DECL_GFX_PREF(Live, "layers.low-precision-opacity", LowPrecisionOpacity, float, 1.0f);
DECL_GFX_PREF(Live, "layers.low-precision-resolution", LowPrecisionResolution, float, 0.25f);