Skip to content

Commit

Permalink
[android-webview] Enable breakpad microdump crash reporting
Browse files Browse the repository at this point in the history
This CL:
 - Pulls in the dependencies required to build breakpad and the
   crash component.
 - Introduces a crash reporter for WebView which unconditionally
   enables microdumps (but not minidump uploads).
 - Introduces a fallback no-op implementation which avoids the burden
   of importing and supporting breakpad in the internal Android builds
   (which are going to be deprecated soon).

Impact of this change on the WebView APK size:
  Before the change: 25700337 bytes
  After the change:  25720974 bytes
  Delta:                20637 bytes

Impact of this change on the uncompressed libwebviewchromium.so lib:
  Before the change: 28547980 bytes
  After the change:  28576844 bytes
  Delta:                28864 bytes

BUG=410294, 456494
TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/902093003

Cr-Commit-Position: refs/heads/master@{#315357}
  • Loading branch information
primiano authored and Commit bot committed Feb 9, 2015
1 parent 93ae819 commit 2d3f4b2
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
18 changes: 18 additions & 0 deletions android_webview/android_webview.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
'common/render_view_messages.h',
'common/url_constants.cc',
'common/url_constants.h',
'crash_reporter/aw_microdump_crash_reporter.h',
'lib/aw_browser_dependency_factory_impl.cc',
'lib/aw_browser_dependency_factory_impl.h',
'lib/main/aw_main_delegate.cc',
Expand All @@ -327,6 +328,23 @@
'renderer/print_render_frame_observer.cc',
'renderer/print_render_frame_observer.h',
],
# TODO(primiano): remove the *_disabled_in_android_builds fallback and
# merge this with the target once android_webview_build goes away.
'conditions': [
['android_webview_build==0', {
'dependencies': [
'../components/components.gyp:breakpad_host',
'../components/components.gyp:crash_component',
],
'sources': [
'crash_reporter/aw_microdump_crash_reporter.cc',
],
}, { # android_webview_build==1
'sources': [
'crash_reporter/aw_microdump_crash_reporter_disabled_in_android_builds.cc',
],
}],
],
},
{
'target_name': 'libwebviewchromium',
Expand Down
3 changes: 3 additions & 0 deletions android_webview/crash_reporter/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+components/crash",
]
54 changes: 54 additions & 0 deletions android_webview/crash_reporter/aw_microdump_crash_reporter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"

#include "base/lazy_instance.h"
#include "components/crash/app/breakpad_linux.h"
#include "components/crash/app/crash_reporter_client.h"

namespace android_webview {
namespace crash_reporter {

namespace {

class AwCrashReporterClient : public ::crash_reporter::CrashReporterClient {
public:
AwCrashReporterClient() {}

// crash_reporter::CrashReporterClient implementation.
bool IsRunningUnattended() override { return false; }
bool GetCollectStatsConsent() override { return false; }

// Microdumps are always enabled in WebView builds, conversely to what happens
// in the case of the other Chrome for Android builds (where they are enabled
// only when NO_UNWIND_TABLES == 1).
bool ShouldEnableBreakpadMicrodumps() override { return true; }

private:
DISALLOW_COPY_AND_ASSIGN(AwCrashReporterClient);
};

base::LazyInstance<AwCrashReporterClient>::Leaky g_crash_reporter_client =
LAZY_INSTANCE_INITIALIZER;

bool g_enabled = false;

} // namespace

void EnableMicrodumpCrashReporter() {
if (g_enabled) {
NOTREACHED() << "EnableMicrodumpCrashReporter called more than once";
return;
}

::crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer());

// |process_type| is not really relevant here, as long as it not empty.
breakpad::InitNonBrowserCrashReporterForAndroid("webview" /* process_type */);
g_enabled = true;
}

} // namespace crash_reporter
} // namespace android_webview
16 changes: 16 additions & 0 deletions android_webview/crash_reporter/aw_microdump_crash_reporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_
#define ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_

namespace android_webview {
namespace crash_reporter {

void EnableMicrodumpCrashReporter();

} // namespace crash_reporter
} // namespace android_webview

#endif // ANDROID_WEBVIEW_CRASH_REPORTER_AW_MICRODUMP_CRASH_REPORTER_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"

// TODO(primiano): remove this once Android builds of WebView are deprecated.
// This translation unit is a no-op fallback for AwCrashReporter. This is built
// only when building in the Android tree.
// The rationale of this hack is to avoid the cost of maintaining breakpad in
// the Android tree, as the WebView build in Android itself is going to be
// deprecated soon (crbug.com/440792).

namespace android_webview {
namespace crash_reporter {

void EnableMicrodumpCrashReporter() {
}

} // namespace crash_reporter
} // namespace android_webview
3 changes: 3 additions & 0 deletions android_webview/lib/main/aw_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "android_webview/browser/aw_content_browser_client.h"
#include "android_webview/browser/browser_view_renderer.h"
#include "android_webview/browser/scoped_allow_wait_for_legacy_web_view_api.h"
#include "android_webview/crash_reporter/aw_microdump_crash_reporter.h"
#include "android_webview/lib/aw_browser_dependency_factory_impl.h"
#include "android_webview/native/aw_assets.h"
#include "android_webview/native/aw_media_url_interceptor.h"
Expand Down Expand Up @@ -123,6 +124,8 @@ void AwMainDelegate::PreSandboxStartup() {
// cpu_brand info.
base::CPU cpu_info;
#endif

crash_reporter::EnableMicrodumpCrashReporter();
}

void AwMainDelegate::SandboxInitialized(const std::string& process_type) {
Expand Down

0 comments on commit 2d3f4b2

Please sign in to comment.