Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander

This commit is contained in:
George Wright 2016-10-31 15:44:40 -04:00
parent 8d3733057e
commit 51a59d1d02
6 changed files with 69 additions and 1 deletions

View File

@ -110,6 +110,7 @@
#include "mozilla/layers/APZCTreeManager.h" // for layers::ZoomToRectBehavior
#include "mozilla/dom/Promise.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/gfx/GPUProcessManager.h"
#ifdef XP_WIN
#undef GetClassName
@ -4092,6 +4093,29 @@ nsDOMWindowUtils::ForceReflowInterrupt()
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::TerminateGPUProcess()
{
GPUProcessManager* pm = GPUProcessManager::Get();
if (pm) {
pm->KillProcess();
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMWindowUtils::GetGpuProcessPid(int32_t* aPid)
{
GPUProcessManager* pm = GPUProcessManager::Get();
if (pm) {
*aPid = pm->GPUProcessPid();
} else {
*aPid = -1;
}
return NS_OK;
}
NS_INTERFACE_MAP_BEGIN(nsTranslationNodeList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsITranslationNodeList)

View File

@ -49,7 +49,7 @@ interface nsIJSRAIIHelper;
interface nsIContentPermissionRequest;
interface nsIObserver;
[scriptable, uuid(46b44e33-13c2-4eb3-bf80-76a4e0857ccc)]
[scriptable, uuid(c471d440-004b-4c50-a6f2-747db5f443b6)]
interface nsIDOMWindowUtils : nsISupports {
/**
@ -1965,6 +1965,16 @@ interface nsIDOMWindowUtils : nsISupports {
*/
void forceReflowInterrupt();
/**
* Terminate the GPU process. Used for testing GPU process restarts.
*/
void terminateGPUProcess();
/**
* Returns the GPU process pid, or -1 if there is no GPU process.
*/
readonly attribute int32_t gpuProcessPid;
const long MOUSE_BUTTONS_NO_BUTTON = 0x00;
const long MOUSE_BUTTONS_LEFT_BUTTON = 0x01;
const long MOUSE_BUTTONS_RIGHT_BUTTON = 0x02;

View File

@ -223,6 +223,12 @@ DelayedDeleteSubprocess(GeckoChildProcessHost* aSubprocess)
PostTask(mozilla::MakeAndAddRef<DeleteTask<GeckoChildProcessHost>>(aSubprocess));
}
void
GPUProcessHost::KillProcess()
{
KillHard("DiagnosticKill");
}
void
GPUProcessHost::DestroyProcess()
{

View File

@ -96,6 +96,9 @@ public:
void SetListener(Listener* aListener);
// Used for tests and diagnostics
void KillProcess();
private:
// Called on the main thread.
void OnChannelConnectedTask();

View File

@ -386,6 +386,16 @@ GPUProcessManager::CleanShutdown()
mVsyncIOThread = nullptr;
}
void
GPUProcessManager::KillProcess()
{
if (!mProcess) {
return;
}
mProcess->KillProcess();
}
void
GPUProcessManager::DestroyProcess()
{
@ -606,6 +616,15 @@ GPUProcessManager::CreateContentImageBridge(base::ProcessId aOtherProcess,
return true;
}
base::ProcessId
GPUProcessManager::GPUProcessPid()
{
base::ProcessId gpuPid = mGPUChild
? mGPUChild->OtherPid()
: -1;
return gpuPid;
}
bool
GPUProcessManager::CreateContentVRManager(base::ProcessId aOtherProcess,
ipc::Endpoint<PVRManagerChild>* aOutEndpoint)

View File

@ -133,6 +133,12 @@ public:
// true if the message was sent, false if not.
bool NotifyGpuObservers(const char* aTopic);
// Used for tests and diagnostics
void KillProcess();
// Returns -1 if there is no GPU process, or the platform pid for it.
base::ProcessId GPUProcessPid();
// Returns access to the PGPU protocol if a GPU process is present.
GPUChild* GetGPUChild() {
return mGPUChild;