Commit f6401b7d authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Fix all process types getting the name "Browser" in the tracelog on Android

This was causing the ProfilingProcessHostAndroidTests to fail with
network service running out of process because the network process was
getting the wrong name. Utility services only set a name on the tracelog
if there is not currently a name set:
https://cs.chromium.org/chromium/src/content/utility/utility_service_factory.cc?l=133&rcl=a2b08947596e1510f3a6fa2f65c2491eeeb4e9ec

This modifies the library loaded hooks to only use the name "Browser" if
this is actually the browser process.

Bug: 872343
Change-Id: I0af79db900a604a11aab0a80c5870a420aca920a
Reviewed-on: https://chromium-review.googlesource.com/c/1300294Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603117}
parent 4fcaee53
......@@ -195,8 +195,12 @@ static jboolean JNI_LibraryLoader_LibraryLoaded(
!g_native_initialization_hook(
static_cast<LibraryProcessType>(library_process_type)))
return false;
if (g_registration_callback && !g_registration_callback(env, nullptr))
if (g_registration_callback &&
!g_registration_callback(
env, nullptr,
static_cast<LibraryProcessType>(library_process_type))) {
return false;
}
return true;
}
......
......@@ -45,7 +45,8 @@ BASE_EXPORT void RecordLibraryLoaderRendererHistograms();
// Note: this can't use base::Callback because there is no way of initializing
// the default callback without using static objects, which we forbid.
typedef bool LibraryLoadedHook(JNIEnv* env,
jclass clazz);
jclass clazz,
LibraryProcessType library_process_type);
// Set the hook function to be called (from Java) once the libraries are loaded.
// SetLibraryLoadedHook may only be called from JNI_OnLoad. The hook function
......
......@@ -4,7 +4,6 @@
#include "content/app/android/library_loader_hooks.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "components/tracing/common/trace_startup.h"
......@@ -12,13 +11,20 @@
namespace content {
bool LibraryLoaded(JNIEnv* env, jclass clazz) {
bool LibraryLoaded(JNIEnv* env,
jclass clazz,
base::android::LibraryProcessType library_process_type) {
// Enable startup tracing asap to avoid early TRACE_EVENT calls being ignored.
tracing::EnableStartupTracingIfNeeded();
// Android's main browser loop is custom so we set the browser
// name here as early as possible.
base::trace_event::TraceLog::GetInstance()->set_process_name("Browser");
// Android's main browser loop is custom so we set the browser name here as
// early as possible if this is the browser process or main webview process.
if (library_process_type ==
base::android::LibraryProcessType::PROCESS_BROWSER ||
library_process_type ==
base::android::LibraryProcessType::PROCESS_WEBVIEW) {
base::trace_event::TraceLog::GetInstance()->set_process_name("Browser");
}
base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex(
kTraceEventBrowserProcessSortIndex);
......
......@@ -7,6 +7,7 @@
#include <jni.h>
#include "base/android/library_loader/library_loader_hooks.h"
namespace content {
......@@ -14,7 +15,9 @@ namespace content {
// has loaded.
// This is designed to be used as a hook function to be passed to
// base::android::SetLibraryLoadedHook
bool LibraryLoaded(JNIEnv* env, jclass clazz);
bool LibraryLoaded(JNIEnv* env,
jclass clazz,
base::android::LibraryProcessType library_process_type);
} // namespace content
......
......@@ -19,15 +19,6 @@
-org.chromium.chrome.browser.customtabs.CustomTabActivityTest.testLaunchWebLiteURL
-org.chromium.chrome.browser.infobar.InfoBarTest.testDataReductionPromoInfoBar
# https://crbug.com/872343
# These only fail with OOP network service.
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowser
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowserAndAllUtility
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowserDynamic
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowserDynamicPseudo
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowserDynamicPseudoSampleEverything
-org.chromium.chrome.browser.profiling_host.ProfilingProcessHostAndroidTest.testModeBrowserDynamicPseudoSamplePartial
# https://crbug.com/888020
# These only fail with OOP network service.
-org.chromium.chrome.browser.HTTPSTabsOpenedFromExternalAppTest.testReferrerPolicyHttpReferrerHttpsNavigationsPolicyDefault
......
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