Support about:checkerboard reporting in the GPU process. (bug 1301266 part 2, r=kats)

This commit is contained in:
David Anderson 2016-09-21 22:38:44 -07:00
parent 4c2e28b8b6
commit 14db343852
8 changed files with 57 additions and 10 deletions

View File

@ -7,6 +7,7 @@
#include "gfxConfig.h"
#include "gfxPrefs.h"
#include "GPUProcessHost.h"
#include "mozilla/dom/CheckerboardReportService.h"
#include "mozilla/gfx/gfxVars.h"
#if defined(XP_WIN)
# include "mozilla/gfx/DeviceManagerDx.h"
@ -93,6 +94,13 @@ GPUChild::RecvInitComplete(const GPUDeviceData& aData)
return true;
}
bool
GPUChild::RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog)
{
layers::CheckerboardEventStorage::Report(aSeverity, std::string(aLog.get()));
return true;
}
void
GPUChild::ActorDestroy(ActorDestroyReason aWhy)
{

View File

@ -33,6 +33,7 @@ public:
// PGPUChild overrides.
bool RecvInitComplete(const GPUDeviceData& aData) override;
bool RecvReportCheckerboard(const uint32_t& aSeverity, const nsCString& aLog) override;
void ActorDestroy(ActorDestroyReason aWhy) override;
static void Destroy(UniquePtr<GPUChild>&& aChild);

View File

@ -41,12 +41,22 @@ namespace gfx {
using namespace ipc;
using namespace layers;
static GPUParent* sGPUParent;
GPUParent::GPUParent()
{
sGPUParent = this;
}
GPUParent::~GPUParent()
{
sGPUParent = nullptr;
}
/* static */ GPUParent*
GPUParent::GetSingleton()
{
return sGPUParent;
}
bool

View File

@ -20,6 +20,8 @@ public:
GPUParent();
~GPUParent();
static GPUParent* GetSingleton();
bool Init(base::ProcessId aParentPid,
MessageLoop* aIOLoop,
IPC::Channel* aChannel);

View File

@ -72,6 +72,9 @@ child:
// Sent when the GPU process has initialized devices. This occurs once, after
// Init().
async InitComplete(GPUDeviceData data);
// Sent when APZ detects checkerboarding and apz checkerboard reporting is enabled.
async ReportCheckerboard(uint32_t severity, nsCString log);
};
} // namespace gfx

View File

@ -3200,10 +3200,7 @@ AsyncPanZoomController::ReportCheckerboard(const TimeStamp& aSampleTime)
// checkerboard events.
uint32_t severity = mCheckerboardEvent->GetSeverity();
std::string log = mCheckerboardEvent->GetLog();
NS_DispatchToMainThread(NS_NewRunnableFunction([severity, log]() {
RefPtr<CheckerboardEventStorage> storage = CheckerboardEventStorage::GetInstance();
storage->ReportCheckerboard(severity, log);
}));
CheckerboardEventStorage::Report(severity, log);
}
mCheckerboardEvent = nullptr;
}

View File

@ -11,6 +11,7 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT
#include "mozilla/ClearOnShutdown.h" // for ClearOnShutdown
#include "mozilla/dom/CheckerboardReportServiceBinding.h" // for dom::CheckerboardReports
#include "mozilla/gfx/GPUParent.h"
#include "nsContentUtils.h" // for nsContentUtils
#include "nsXULAppAPI.h"
@ -35,6 +36,29 @@ CheckerboardEventStorage::GetInstance()
return instance.forget();
}
void
CheckerboardEventStorage::Report(uint32_t aSeverity, const std::string& aLog)
{
if (!NS_IsMainThread()) {
RefPtr<Runnable> task = NS_NewRunnableFunction([aSeverity, aLog] () -> void {
CheckerboardEventStorage::Report(aSeverity, aLog);
});
NS_DispatchToMainThread(task.forget());
return;
}
if (XRE_IsGPUProcess()) {
if (gfx::GPUParent* gpu = gfx::GPUParent::GetSingleton()) {
nsCString log(aLog.c_str());
gpu->SendReportCheckerboard(aSeverity, log);
}
return;
}
RefPtr<CheckerboardEventStorage> storage = GetInstance();
storage->ReportCheckerboard(aSeverity, aLog);
}
void
CheckerboardEventStorage::ReportCheckerboard(uint32_t aSeverity, const std::string& aLog)
{

View File

@ -37,17 +37,17 @@ public:
*/
static already_AddRefed<CheckerboardEventStorage> GetInstance();
/**
* Save a checkerboard event log, optionally dropping older ones that were
* less severe or less recent. Zero-severity reports may be ignored entirely.
*/
void ReportCheckerboard(uint32_t aSeverity, const std::string& aLog);
/**
* Get the stored checkerboard reports.
*/
void GetReports(nsTArray<dom::CheckerboardReport>& aOutReports);
/**
* Save a checkerboard event log, optionally dropping older ones that were
* less severe or less recent. Zero-severity reports may be ignored entirely.
*/
static void Report(uint32_t aSeverity, const std::string& aLog);
private:
/* Stuff for refcounted singleton */
CheckerboardEventStorage() {}
@ -55,6 +55,8 @@ private:
static StaticRefPtr<CheckerboardEventStorage> sInstance;
void ReportCheckerboard(uint32_t aSeverity, const std::string& aLog);
private:
/**
* Struct that this class uses internally to store a checkerboard report.