mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 818307: Part 2 - Plugin Hang UI ChromeHang annotations; r=gfritzsche
This commit is contained in:
parent
e4b4c2c78b
commit
59ddd89c31
@ -356,6 +356,7 @@ PluginHangUIParent::RecvUserResponse(const unsigned int& aResponse)
|
||||
mModule->TerminateChildProcess(mMainThreadMessageLoop);
|
||||
responseCode = 1;
|
||||
} else if(aResponse & HANGUI_USER_RESPONSE_CONTINUE) {
|
||||
mModule->OnHangUIContinue();
|
||||
// User clicked Continue
|
||||
responseCode = 2;
|
||||
} else {
|
||||
|
@ -134,6 +134,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
, mNPNIface(nullptr)
|
||||
, mPlugin(nullptr)
|
||||
, mTaskFactory(MOZ_THIS_IN_INITIALIZER_LIST())
|
||||
, mHangAnnotationFlags(0)
|
||||
#ifdef XP_WIN
|
||||
, mPluginCpuUsageOnHang()
|
||||
, mHangUIParent(nullptr)
|
||||
@ -161,6 +162,8 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
#ifdef MOZ_ENABLE_PROFILER_SPS
|
||||
InitPluginProfiling();
|
||||
#endif
|
||||
|
||||
mozilla::HangMonitor::RegisterAnnotator(*this);
|
||||
}
|
||||
|
||||
PluginModuleParent::~PluginModuleParent()
|
||||
@ -204,6 +207,8 @@ PluginModuleParent::~PluginModuleParent()
|
||||
mHangUIParent = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
mozilla::HangMonitor::UnregisterAnnotator(*this);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@ -225,20 +230,8 @@ PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes)
|
||||
filePos++;
|
||||
notes.Put(NS_LITERAL_CSTRING("PluginFilename"), CS(pluginFile.substr(filePos).c_str()));
|
||||
|
||||
nsCString pluginName;
|
||||
nsCString pluginVersion;
|
||||
|
||||
nsRefPtr<nsPluginHost> ph = nsPluginHost::GetInst();
|
||||
if (ph) {
|
||||
nsPluginTag* tag = ph->TagForPlugin(mPlugin);
|
||||
if (tag) {
|
||||
pluginName = tag->mName;
|
||||
pluginVersion = tag->mVersion;
|
||||
}
|
||||
}
|
||||
|
||||
notes.Put(NS_LITERAL_CSTRING("PluginName"), pluginName);
|
||||
notes.Put(NS_LITERAL_CSTRING("PluginVersion"), pluginVersion);
|
||||
notes.Put(NS_LITERAL_CSTRING("PluginName"), mPluginName);
|
||||
notes.Put(NS_LITERAL_CSTRING("PluginVersion"), mPluginVersion);
|
||||
|
||||
CrashReporterParent* crashReporter = CrashReporter();
|
||||
if (crashReporter) {
|
||||
@ -390,13 +383,52 @@ GetProcessCpuUsage(const InfallibleTArray<base::ProcessHandle>& processHandles,
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#endif // #ifdef XP_WIN
|
||||
|
||||
void
|
||||
PluginModuleParent::EnteredCxxStack()
|
||||
{
|
||||
mHangAnnotationFlags |= kInPluginCall;
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::ExitedCxxStack()
|
||||
{
|
||||
mHangAnnotationFlags = 0;
|
||||
#ifdef XP_WIN
|
||||
FinishHangUI();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // #ifdef XP_WIN
|
||||
/**
|
||||
* This function is always called by the HangMonitor thread.
|
||||
*/
|
||||
void
|
||||
PluginModuleParent::AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations)
|
||||
{
|
||||
uint32_t flags = mHangAnnotationFlags;
|
||||
if (flags) {
|
||||
/* We don't actually annotate anything specifically for kInPluginCall;
|
||||
we use it to determine whether to annotate other things. It will
|
||||
be pretty obvious from the ChromeHang stack that we're in a plugin
|
||||
call when the hang occurred. */
|
||||
if (flags & kHangUIShown) {
|
||||
aAnnotations.AddAnnotation(NS_LITERAL_STRING("HangUIShown"),
|
||||
true);
|
||||
}
|
||||
if (flags & kHangUIContinued) {
|
||||
aAnnotations.AddAnnotation(NS_LITERAL_STRING("HangUIContinued"),
|
||||
true);
|
||||
}
|
||||
if (flags & kHangUIDontShow) {
|
||||
aAnnotations.AddAnnotation(NS_LITERAL_STRING("HangUIDontShow"),
|
||||
true);
|
||||
}
|
||||
aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginName"), mPluginName);
|
||||
aAnnotations.AddAnnotation(NS_LITERAL_STRING("pluginVersion"),
|
||||
mPluginVersion);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
static bool
|
||||
@ -532,6 +564,23 @@ PluginModuleParent::TerminateChildProcess(MessageLoop* aMsgLoop)
|
||||
NS_WARNING("failed to kill subprocess!");
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::GetPluginDetails(nsACString& aPluginName,
|
||||
nsACString& aPluginVersion)
|
||||
{
|
||||
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
||||
if (!host) {
|
||||
return false;
|
||||
}
|
||||
nsPluginTag* pluginTag = host->TagForPlugin(mPlugin);
|
||||
if (!pluginTag) {
|
||||
return false;
|
||||
}
|
||||
aPluginName = pluginTag->mName;
|
||||
aPluginVersion = pluginTag->mVersion;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
void
|
||||
PluginModuleParent::EvaluateHangUIState(const bool aReset)
|
||||
@ -567,21 +616,6 @@ PluginModuleParent::EvaluateHangUIState(const bool aReset)
|
||||
SetChildTimeout(autoStopSecs);
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::GetPluginName(nsAString& aPluginName)
|
||||
{
|
||||
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
||||
if (!host) {
|
||||
return false;
|
||||
}
|
||||
nsPluginTag* pluginTag = host->TagForPlugin(mPlugin);
|
||||
if (!pluginTag) {
|
||||
return false;
|
||||
}
|
||||
CopyUTF8toUTF16(pluginTag->mName, aPluginName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::LaunchHangUI()
|
||||
{
|
||||
@ -594,7 +628,12 @@ PluginModuleParent::LaunchHangUI()
|
||||
return false;
|
||||
}
|
||||
if (mHangUIParent->DontShowAgain()) {
|
||||
return !mHangUIParent->WasLastHangStopped();
|
||||
mHangAnnotationFlags |= kHangUIDontShow;
|
||||
bool wasLastHangStopped = mHangUIParent->WasLastHangStopped();
|
||||
if (!wasLastHangStopped) {
|
||||
mHangAnnotationFlags |= kHangUIContinued;
|
||||
}
|
||||
return !wasLastHangStopped;
|
||||
}
|
||||
delete mHangUIParent;
|
||||
mHangUIParent = nullptr;
|
||||
@ -602,12 +641,9 @@ PluginModuleParent::LaunchHangUI()
|
||||
mHangUIParent = new PluginHangUIParent(this,
|
||||
Preferences::GetInt(kHangUITimeoutPref, 0),
|
||||
Preferences::GetInt(kChildTimeoutPref, 0));
|
||||
nsAutoString pluginName;
|
||||
if (!GetPluginName(pluginName)) {
|
||||
return false;
|
||||
}
|
||||
bool retval = mHangUIParent->Init(pluginName);
|
||||
bool retval = mHangUIParent->Init(NS_ConvertUTF8toUTF16(mPluginName));
|
||||
if (retval) {
|
||||
mHangAnnotationFlags |= kHangUIShown;
|
||||
/* Once the UI is shown we switch the timeout over to use
|
||||
kChildTimeoutPref, allowing us to terminate a hung plugin
|
||||
after kChildTimeoutPref seconds if the user doesn't respond to
|
||||
@ -637,6 +673,12 @@ PluginModuleParent::FinishHangUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginModuleParent::OnHangUIContinue()
|
||||
{
|
||||
mHangAnnotationFlags |= kHangUIContinued;
|
||||
}
|
||||
#endif // XP_WIN
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
@ -1340,6 +1382,10 @@ PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mPluginName.IsEmpty()) {
|
||||
GetPluginDetails(mPluginName, mPluginVersion);
|
||||
}
|
||||
|
||||
// create the instance on the other side
|
||||
InfallibleTArray<nsCString> names;
|
||||
InfallibleTArray<nsCString> values;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "base/process.h"
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/HangMonitor.h"
|
||||
#include "mozilla/PluginLibrary.h"
|
||||
#include "mozilla/plugins/ScopedMethodFactory.h"
|
||||
#include "mozilla/plugins/PluginProcessParent.h"
|
||||
@ -59,6 +60,7 @@ class PluginModuleParent
|
||||
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
||||
, public CrashReporter::InjectorCrashCallback
|
||||
#endif
|
||||
, public mozilla::HangMonitor::Annotator
|
||||
{
|
||||
private:
|
||||
typedef mozilla::PluginLibrary PluginLibrary;
|
||||
@ -129,10 +131,23 @@ public:
|
||||
|
||||
void TerminateChildProcess(MessageLoop* aMsgLoop);
|
||||
|
||||
#ifdef XP_WIN
|
||||
void
|
||||
virtual void
|
||||
EnteredCxxStack() MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
ExitedCxxStack() MOZ_OVERRIDE;
|
||||
#endif // XP_WIN
|
||||
|
||||
virtual void
|
||||
AnnotateHang(mozilla::HangMonitor::HangAnnotations& aAnnotations) MOZ_OVERRIDE;
|
||||
|
||||
#ifdef XP_WIN
|
||||
/**
|
||||
* Called by Plugin Hang UI to notify that the user has clicked continue.
|
||||
* Used for chrome hang annotations.
|
||||
*/
|
||||
void
|
||||
OnHangUIContinue();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual mozilla::ipc::RacyInterruptPolicy
|
||||
@ -305,6 +320,16 @@ private:
|
||||
nsString mBrowserDumpID;
|
||||
nsString mHangID;
|
||||
nsRefPtr<nsIObserver> mProfilerObserver;
|
||||
enum HangAnnotationFlags
|
||||
{
|
||||
kInPluginCall = (1u << 0),
|
||||
kHangUIShown = (1u << 1),
|
||||
kHangUIContinued = (1u << 2),
|
||||
kHangUIDontShow = (1u << 3)
|
||||
};
|
||||
Atomic<uint32_t> mHangAnnotationFlags;
|
||||
nsCString mPluginName;
|
||||
nsCString mPluginVersion;
|
||||
#ifdef XP_WIN
|
||||
InfallibleTArray<float> mPluginCpuUsageOnHang;
|
||||
PluginHangUIParent *mHangUIParent;
|
||||
@ -325,9 +350,6 @@ private:
|
||||
void
|
||||
EvaluateHangUIState(const bool aReset);
|
||||
|
||||
bool
|
||||
GetPluginName(nsAString& aPluginName);
|
||||
|
||||
/**
|
||||
* Launches the Plugin Hang UI.
|
||||
*
|
||||
@ -345,6 +367,9 @@ private:
|
||||
FinishHangUI();
|
||||
#endif
|
||||
|
||||
bool
|
||||
GetPluginDetails(nsACString& aPluginName, nsACString& aPluginVersion);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// Dup of plugin's X socket, used to scope its resources to this
|
||||
// object instead of the plugin process's lifetime
|
||||
|
Loading…
Reference in New Issue
Block a user