mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout ac8d6c79a074 (bug 781133) and fccc68cc904f (bug 781124) for Windows bustage on a CLOSED TREE.
This commit is contained in:
parent
fe19c64718
commit
1cecad8f26
@ -33,7 +33,6 @@
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
#include "prsystem.h"
|
||||
#include "prdtoa.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "mozilla/widget/AudioSession.h"
|
||||
@ -111,7 +110,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
, mPlugin(NULL)
|
||||
, mTaskFactory(this)
|
||||
#ifdef XP_WIN
|
||||
, mPluginCpuUsageOnHang()
|
||||
, mPluginCpuUsageOnHang(-1)
|
||||
#endif
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
, mFlashProcess1(0)
|
||||
@ -179,18 +178,11 @@ PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes)
|
||||
if (!hangID.IsEmpty()) {
|
||||
notes.Put(CS("HangID"), NS_ConvertUTF16toUTF8(hangID));
|
||||
#ifdef XP_WIN
|
||||
if (mPluginCpuUsageOnHang.Length() > 0) {
|
||||
if (mPluginCpuUsageOnHang >= 0) {
|
||||
notes.Put(CS("PluginCpuUsage"),
|
||||
nsPrintfCString("%.2f", mPluginCpuUsageOnHang));
|
||||
notes.Put(CS("NumberOfProcessors"),
|
||||
nsPrintfCString("%d", PR_GetNumberOfProcessors()));
|
||||
|
||||
char buf[7];
|
||||
PR_cnvtf(buf, NS_ARRAY_LENGTH(buf), 2, mPluginCpuUsageOnHang[0]);
|
||||
notes.Put(CS("PluginCpuUsage"), CS(buf));
|
||||
|
||||
for (PRInt32 i=1; i<mPluginCpuUsageOnHang.Length(); ++i) {
|
||||
PR_cnvtf(buf, NS_ARRAY_LENGTH(buf), 2, mPluginCpuUsageOnHang[i]);
|
||||
notes.Put(nsPrintfCString("CpuUsageFlashProcess%d", i), CS(buf));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -235,53 +227,42 @@ FileTimeToUTC(const FILETIME& ftime)
|
||||
return li.QuadPart;
|
||||
}
|
||||
|
||||
struct CpuUsageSamples
|
||||
{
|
||||
PRUint64 sampleTimes[2];
|
||||
PRUint64 cpuTimes[2];
|
||||
};
|
||||
|
||||
bool
|
||||
GetProcessCpuUsage(const InfallibleTArray<base::ProcessHandle>& processHandles, InfallibleTArray<float>& cpuUsage)
|
||||
GetProcessCpuUsage(const base::ProcessHandle& processHandle, float& cpuUsage)
|
||||
{
|
||||
InfallibleTArray<CpuUsageSamples> samples(processHandles.Length());
|
||||
FILETIME creationTime, exitTime, kernelTime, userTime, currentTime;
|
||||
BOOL res;
|
||||
|
||||
for (PRUint32 i = 0; i < processHandles.Length(); ++i) {
|
||||
::GetSystemTimeAsFileTime(¤tTime);
|
||||
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime);
|
||||
if (!res) {
|
||||
NS_WARNING("failed to get process times");
|
||||
return false;
|
||||
}
|
||||
|
||||
samples[i].sampleTimes[0] = FileTimeToUTC(currentTime);
|
||||
samples[i].cpuTimes[0] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
||||
::GetSystemTimeAsFileTime(¤tTime);
|
||||
res = ::GetProcessTimes(processHandle, &creationTime, &exitTime, &kernelTime, &userTime);
|
||||
if (!res) {
|
||||
NS_WARNING("failed to get process times");
|
||||
return false;
|
||||
}
|
||||
|
||||
PRUint64 sampleTimes[2];
|
||||
PRUint64 cpuTimes[2];
|
||||
|
||||
sampleTimes[0] = FileTimeToUTC(currentTime);
|
||||
cpuTimes[0] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
||||
|
||||
// we already hung for a while, a little bit longer won't matter
|
||||
::Sleep(50);
|
||||
|
||||
const PRInt32 numberOfProcessors = PR_GetNumberOfProcessors();
|
||||
|
||||
for (PRUint32 i = 0; i < processHandles.Length(); ++i) {
|
||||
::GetSystemTimeAsFileTime(¤tTime);
|
||||
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime);
|
||||
if (!res) {
|
||||
NS_WARNING("failed to get process times");
|
||||
return false;
|
||||
}
|
||||
|
||||
samples[i].sampleTimes[1] = FileTimeToUTC(currentTime);
|
||||
samples[i].cpuTimes[1] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
||||
|
||||
const PRUint64 deltaSampleTime = samples[i].sampleTimes[1] - samples[i].sampleTimes[0];
|
||||
const PRUint64 deltaCpuTime = samples[i].cpuTimes[1] - samples[i].cpuTimes[0];
|
||||
const float usage = 100.f * (float(deltaCpuTime) / deltaSampleTime) / numberOfProcessors;
|
||||
cpuUsage.AppendElement(usage);
|
||||
::GetSystemTimeAsFileTime(¤tTime);
|
||||
res = ::GetProcessTimes(processHandle, &creationTime, &exitTime, &kernelTime, &userTime);
|
||||
if (!res) {
|
||||
NS_WARNING("failed to get process times");
|
||||
return false;
|
||||
}
|
||||
|
||||
sampleTimes[1] = FileTimeToUTC(currentTime);
|
||||
cpuTimes[1] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
||||
|
||||
const PRUint64 deltaSampleTime = sampleTimes[1] - sampleTimes[0];
|
||||
const PRUint64 deltaCpuTime = cpuTimes[1] - cpuTimes[0];
|
||||
cpuUsage = 100.f * (float(deltaCpuTime) / deltaSampleTime) / PR_GetNumberOfProcessors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -307,22 +288,9 @@ PluginModuleParent::ShouldContinueFromReplyTimeout()
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
// collect cpu usage for plugin processes
|
||||
|
||||
InfallibleTArray<base::ProcessHandle> processHandles;
|
||||
InfallibleTArray<float> cpuUsage;
|
||||
base::ProcessHandle handle;
|
||||
|
||||
processHandles.AppendElement(OtherProcess());
|
||||
if (mFlashProcess1 && base::OpenProcessHandle(mFlashProcess1, &handle)) {
|
||||
processHandles.AppendElement(handle);
|
||||
}
|
||||
if (mFlashProcess2 && base::OpenProcessHandle(mFlashProcess2, &handle)) {
|
||||
processHandles.AppendElement(handle);
|
||||
}
|
||||
|
||||
if (!GetProcessCpuUsage(processHandles, cpuUsage)) {
|
||||
mPluginCpuUsageOnHang.Clear();
|
||||
float cpuUsage;
|
||||
if (GetProcessCpuUsage(OtherProcess(), cpuUsage)) {
|
||||
mPluginCpuUsageOnHang = cpuUsage;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -302,7 +302,7 @@ private:
|
||||
nsString mBrowserDumpID;
|
||||
nsString mHangID;
|
||||
#ifdef XP_WIN
|
||||
InfallibleTArray<float> mPluginCpuUsageOnHang;
|
||||
float mPluginCpuUsageOnHang;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
|
@ -79,7 +79,7 @@ var testObserver = {
|
||||
// check cpu usage field
|
||||
let extraData = parseKeyValuePairsFromFile(pluginExtraFile);
|
||||
ok("PluginCpuUsage" in extraData, "got extra field for plugin cpu usage");
|
||||
let cpuUsage = parseFloat(extraData["PluginCpuUsage"]);
|
||||
let cpuUsage = parseFloat(extraData["PluginCpuUsage"].replace(',', '.'));
|
||||
if (this.idleHang) {
|
||||
ok(cpuUsage == 0, "plugin cpu usage is 0%");
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user