Commit bbf7c843 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Commit Bot

webview: store the app process name in a crash key.

In the browser process, store the current process name (i.e. the app's
process name) in a crash key, so we can see which app process the
crashes originate from in apps with multiple processes.

In renderer processes this isn't relevant since the process name is
always our own sandboxed process.

Change-Id: I4e0ecb20c064cb06c8905938646c8927aa36b9e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2252942
Auto-Submit: Richard Coles <torne@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781423}
parent 35a700ef
......@@ -8,9 +8,12 @@
#include "android_webview/browser/lifecycle/aw_contents_lifecycle_notifier.h"
#include "android_webview/browser/metrics/visibility_metrics_logger.h"
#include "android_webview/browser_jni_headers/AwBrowserProcess_jni.h"
#include "android_webview/common/crash_reporter/crash_keys.h"
#include "base/android/jni_string.h"
#include "base/base_paths_posix.h"
#include "base/path_service.h"
#include "base/task/thread_pool.h"
#include "components/crash/core/common/crash_key.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
......@@ -199,4 +202,12 @@ void AwBrowserProcess::TriggerMinidumpUploading() {
base::android::AttachCurrentThread());
}
static void JNI_AwBrowserProcess_SetProcessNameCrashKey(
JNIEnv* env,
const base::android::JavaParamRef<jstring>& processName) {
static ::crash_reporter::CrashKeyString<64> crash_key(
crash_keys::kAppProcessName);
crash_key.Set(ConvertJavaStringToUTF8(env, processName));
}
} // namespace android_webview
......@@ -12,6 +12,7 @@ namespace crash_keys {
const char kAppPackageName[] = "app-package-name";
const char kAppPackageVersionCode[] = "app-package-version-code";
const char kAppProcessName[] = "app-process-name";
const char kAndroidSdkInt[] = "android-sdk-int";
......@@ -24,6 +25,7 @@ extern const char kWeblayerWebViewCompatMode[] =
const char* const kWebViewCrashKeyAllowList[] = {
kAppPackageName,
kAppPackageVersionCode,
kAppProcessName,
kAndroidSdkInt,
kSupportLibraryWebkitVersion,
......
......@@ -19,6 +19,7 @@ extern const char* const kWebViewCrashKeyAllowList[];
// Application information.
extern const char kAppPackageName[];
extern const char kAppPackageVersionCode[];
extern const char kAppProcessName[];
extern const char kAndroidSdkInt[];
......
......@@ -35,6 +35,7 @@ import org.chromium.base.ThreadUtils;
import org.chromium.base.TimeUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.base.metrics.RecordHistogram;
......@@ -125,6 +126,7 @@ public final class AwBrowserProcess {
public static void start() {
try (ScopedSysTraceEvent e1 = ScopedSysTraceEvent.scoped("AwBrowserProcess.start")) {
final Context appContext = ContextUtils.getApplicationContext();
AwBrowserProcessJni.get().setProcessNameCrashKey(ContextUtils.getProcessName());
AwDataDirLock.lock(appContext);
// We must post to the UI thread to cover the case that the user
// has invoked Chromium startup by using the (thread-safe)
......@@ -437,4 +439,9 @@ public final class AwBrowserProcess {
// Do not instantiate this class.
private AwBrowserProcess() {}
@NativeMethods
interface Natives {
void setProcessNameCrashKey(String processName);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment