Bug 1416686 - Reduce the uses of IPC_FAIL_NO_REASON in GMPChild.cpp.
Originally, we use IPC_FAIL_NO_REASON to make IPC call return error and then it invokes MOZ_CRASH to kill the process itself.
By using IPC_FAIL, we can pass a descriptive reason to GMPChild::ProcessingError and
Bug 1416667 will use MOZ_CRASH_UNSAFE_PRINTF
to print the reason to the crash report. In addition, we use CrashReporter::AnnotateCrashReport to record the lib path without exposing the data publicly.
MozReview-Commit-ID: 15n1PItLgAp
--- a/dom/media/gmp/GMPChild.cpp
+++ b/dom/media/gmp/GMPChild.cpp
@@ -6,16 +6,17 @@
#include "GMPChild.h"
#include "GMPContentChild.h"
#include "GMPProcessChild.h"
#include "GMPLoader.h"
#include "GMPVideoDecoderChild.h"
#include "GMPVideoEncoderChild.h"
#include "GMPVideoHost.h"
#include "nsDebugImpl.h"
+#include "nsExceptionHandler.h"
#include "nsIFile.h"
#include "nsXULAppAPI.h"
#include "gmp-video-decode.h"
#include "gmp-video-encode.h"
#include "GMPPlatform.h"
#include "mozilla/ipc/CrashReporterClient.h"
#include "mozilla/ipc/ProcessChild.h"
#include "GMPUtils.h"
@@ -540,57 +541,84 @@ ToCString(const nsTArray<Pair<nsCString,
mozilla::ipc::IPCResult
GMPChild::AnswerStartPlugin(const nsString& aAdapter)
{
LOGD("%s", __FUNCTION__);
nsCString libPath;
if (!GetUTF8LibPath(libPath)) {
- return IPC_FAIL_NO_REASON(this);
+ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GMPLibraryPath"),
+ NS_ConvertUTF16toUTF8(mPluginPath));
+
+#ifdef XP_WIN
+ return IPC_FAIL(
+ this,
+ nsPrintfCString("Failed to get lib path with error(%d).", GetLastError())
+ .get());
+#else
+ return IPC_FAIL(
+ this,
+ "Failed to get lib path.");
+#endif
}
auto platformAPI = new GMPPlatformAPI();
InitPlatformAPI(*platformAPI, this);
mGMPLoader = MakeUnique<GMPLoader>();
#if defined(MOZ_GMP_SANDBOX)
if (!mGMPLoader->CanSandbox()) {
LOGD("%s Can't sandbox GMP, failing", __FUNCTION__);
delete platformAPI;
- return IPC_FAIL_NO_REASON(this);
+ return IPC_FAIL(this, "Can't sandbox GMP.");
}
#endif
bool isChromium = aAdapter.EqualsLiteral("chromium");
#if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX)
MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default;
if (isChromium) {
pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine;
}
if (!SetMacSandboxInfo(pluginType)) {
NS_WARNING("Failed to set Mac GMP sandbox info");
delete platformAPI;
- return IPC_FAIL_NO_REASON(this);
+ return IPC_FAIL(
+ this,
+ nsPrintfCString("Failed to set Mac GMP sandbox info with plugin type %d.",
+ pluginType).get());
}
#endif
GMPAdapter* adapter = nullptr;
if (isChromium) {
auto&& paths = MakeCDMHostVerificationPaths();
GMP_LOG("%s CDM host paths=%s", __func__, ToCString(paths).get());
adapter = new ChromiumCDMAdapter(Move(paths));
}
if (!mGMPLoader->Load(libPath.get(),
libPath.Length(),
platformAPI,
adapter)) {
NS_WARNING("Failed to load GMP");
delete platformAPI;
- return IPC_FAIL_NO_REASON(this);
+ CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("GMPLibraryPath"),
+ NS_ConvertUTF16toUTF8(mPluginPath));
+
+#ifdef XP_WIN
+ return IPC_FAIL(
+ this,
+ nsPrintfCString("Failed to load GMP with error(%d).", GetLastError())
+ .get());
+#else
+ return IPC_FAIL(
+ this,
+ "Failed to load GMP.");
+#endif
}
return IPC_OK();
}
MessageLoop*
GMPChild::GMPMessageLoop()
{