Commit fe1a134d authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

[heap profiler] Reenable sampling profiler on Android.

It has been temporarily disabled within r666174.

BUG=973430

Change-Id: I747e166f1c6dcba478da897d0c661c5bb6cf2371
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1726661Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682977}
parent c19200de
...@@ -1874,6 +1874,7 @@ if (is_android) { ...@@ -1874,6 +1874,7 @@ if (is_android) {
"//chrome/browser/ui", "//chrome/browser/ui",
"//chrome/child", "//chrome/child",
"//chrome/common", "//chrome/common",
"//chrome/common/profiler",
"//chrome/gpu", "//chrome/gpu",
"//chrome/renderer", "//chrome/renderer",
"//components/gwp_asan/buildflags", "//components/gwp_asan/buildflags",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "chrome/browser/android/chrome_startup_flags.h" #include "chrome/browser/android/chrome_startup_flags.h"
#include "chrome/browser/android/metrics/uma_utils.h" #include "chrome/browser/android/metrics/uma_utils.h"
#include "chrome/common/profiler/main_thread_stack_sampling_profiler.h"
#include "components/policy/core/browser/android/android_combined_policy_provider.h" #include "components/policy/core/browser/android/android_combined_policy_provider.h"
#include "components/safe_browsing/buildflags.h" #include "components/safe_browsing/buildflags.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h" #include "components/startup_metric_utils/browser/startup_metric_utils.h"
...@@ -25,17 +26,16 @@ ...@@ -25,17 +26,16 @@
using safe_browsing::SafeBrowsingApiHandler; using safe_browsing::SafeBrowsingApiHandler;
// ChromeMainDelegateAndroid is created when the library is loaded. It is always // ChromeMainDelegateAndroid is created when the library is loaded. It is always
// done in the process's main Java thread. But for non browser process, e.g. // done in the process' main Java thread. But for a non-browser process, e.g.
// renderer process, it is not the native Chrome's main thread. // renderer process, it is not the native Chrome's main thread.
ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() { ChromeMainDelegateAndroid::ChromeMainDelegateAndroid() = default;
} ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() = default;
ChromeMainDelegateAndroid::~ChromeMainDelegateAndroid() {
}
bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) { bool ChromeMainDelegateAndroid::BasicStartupComplete(int* exit_code) {
// Start the sampling profiler as early as possible.
sampling_profiler_ = std::make_unique<MainThreadStackSamplingProfiler>();
#if BUILDFLAG(SAFE_BROWSING_DB_REMOTE) #if BUILDFLAG(SAFE_BROWSING_DB_REMOTE)
safe_browsing_api_handler_.reset( safe_browsing_api_handler_.reset(
new safe_browsing::SafeBrowsingApiHandlerBridge()); new safe_browsing::SafeBrowsingApiHandlerBridge());
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "components/safe_browsing/buildflags.h" #include "components/safe_browsing/buildflags.h"
#include "content/public/browser/browser_main_runner.h" #include "content/public/browser/browser_main_runner.h"
class MainThreadStackSamplingProfiler;
namespace safe_browsing { namespace safe_browsing {
class SafeBrowsingApiHandler; class SafeBrowsingApiHandler;
} }
...@@ -32,6 +34,7 @@ class ChromeMainDelegateAndroid : public ChromeMainDelegate { ...@@ -32,6 +34,7 @@ class ChromeMainDelegateAndroid : public ChromeMainDelegate {
void ProcessExiting(const std::string& process_type) override; void ProcessExiting(const std::string& process_type) override;
private: private:
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler_;
std::unique_ptr<content::BrowserMainRunner> browser_runner_; std::unique_ptr<content::BrowserMainRunner> browser_runner_;
#if BUILDFLAG(SAFE_BROWSING_DB_REMOTE) #if BUILDFLAG(SAFE_BROWSING_DB_REMOTE)
......
...@@ -159,12 +159,8 @@ std::unique_ptr<ThreadProfiler> ThreadProfiler::CreateAndStartOnMainThread() { ...@@ -159,12 +159,8 @@ std::unique_ptr<ThreadProfiler> ThreadProfiler::CreateAndStartOnMainThread() {
// static // static
void ThreadProfiler::SetMainThreadTaskRunner( void ThreadProfiler::SetMainThreadTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
#if !defined(OS_ANDROID)
// TODO(asvitkine): The code path where we create the profiler instance in
// chrome_main.cc does not run on Android.
DCHECK(g_main_thread_instance); DCHECK(g_main_thread_instance);
g_main_thread_instance->SetMainThreadTaskRunnerImpl(task_runner); g_main_thread_instance->SetMainThreadTaskRunnerImpl(task_runner);
#endif
} }
void ThreadProfiler::SetAuxUnwinderFactory( void ThreadProfiler::SetAuxUnwinderFactory(
......
...@@ -5673,6 +5673,7 @@ test("chrome_app_unittests") { ...@@ -5673,6 +5673,7 @@ test("chrome_app_unittests") {
"//base/test:test_support", "//base/test:test_support",
"//chrome/browser", "//chrome/browser",
"//chrome/child", "//chrome/child",
"//chrome/common/profiler",
"//chrome/gpu", "//chrome/gpu",
"//components/crash/core/common", "//components/crash/core/common",
"//components/flags_ui:switches", "//components/flags_ui:switches",
......
...@@ -200,14 +200,12 @@ int LaunchChromeTests(size_t parallel_jobs, ...@@ -200,14 +200,12 @@ int LaunchChromeTests(size_t parallel_jobs,
const auto& command_line = *base::CommandLine::ForCurrentProcess(); const auto& command_line = *base::CommandLine::ForCurrentProcess();
#if !defined(OS_ANDROID)
// Initialize sampling profiler for tests that relaunching a browser. This // Initialize sampling profiler for tests that relaunching a browser. This
// mimics the behavior in standalone Chrome, where this is done in // mimics the behavior in standalone Chrome, where this is done in
// chrome/app/chrome_main.cc, which does not get called by tests. // chrome/app/chrome_main.cc, which does not get called by tests.
std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler; std::unique_ptr<MainThreadStackSamplingProfiler> sampling_profiler;
if (command_line.HasSwitch(content::kLaunchAsBrowser)) if (command_line.HasSwitch(content::kLaunchAsBrowser))
sampling_profiler = std::make_unique<MainThreadStackSamplingProfiler>(); sampling_profiler = std::make_unique<MainThreadStackSamplingProfiler>();
#endif
#if defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_LINUX) || defined(OS_ANDROID)
ChromeCrashReporterClient::Create(); ChromeCrashReporterClient::Create();
......
...@@ -250,12 +250,8 @@ void CallStackProfileBuilder::SetParentProfileCollectorForChildProcess( ...@@ -250,12 +250,8 @@ void CallStackProfileBuilder::SetParentProfileCollectorForChildProcess(
void CallStackProfileBuilder::PassProfilesToMetricsProvider( void CallStackProfileBuilder::PassProfilesToMetricsProvider(
SampledProfile sampled_profile) { SampledProfile sampled_profile) {
if (sampled_profile.process() == BROWSER_PROCESS) { if (sampled_profile.process() == BROWSER_PROCESS) {
// TODO(crbug.com/973430): Remove the check once profile reporting on
// Android is sorted out.
#if !defined(OS_ANDROID)
GetBrowserProcessReceiverCallbackInstance().Run(profile_start_time_, GetBrowserProcessReceiverCallbackInstance().Run(profile_start_time_,
std::move(sampled_profile)); std::move(sampled_profile));
#endif
} else { } else {
g_child_call_stack_profile_collector.Get() g_child_call_stack_profile_collector.Get()
.ChildCallStackProfileCollector::Collect(profile_start_time_, .ChildCallStackProfileCollector::Collect(profile_start_time_,
......
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