Commit c7fec141 authored by Tobias Sargeant's avatar Tobias Sargeant Committed by Commit Bot

[wv] Change Java exception filtering logic to use proguard sourcefile.

Now that proguarded builds set sourcefile to a recognisable string, we
can use that to determine if a stack frame references Chromium code.

Also add the prefixes of other Chromium packages so that this continues
to work in the un-proguarded case.

Bug: 1044585
Change-Id: I6ce03c09da4de8942cd2db6436700f83ab93b141
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2059970Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743141}
parent b6099f6e
......@@ -14,10 +14,9 @@ import org.chromium.base.annotations.JNINamespace;
*/
@JNINamespace("android_webview")
public class AwCrashReporterClient {
// The filename prefix used by GMS proguarding, which we use to recognise
// otherwise colliding proguarded class names as belonging to dynamite
// modules.
private static final String DYNAMITE_PREFIX = ":com.google.android.gms";
// The filename prefix used by Chromium proguarding, which we use to
// recognise stack frames that reference WebView.
private static final String CHROMIUM_PREFIX = "chromium-";
/**
* Determine if a Throwable should be reported to the crash reporting mechanism.
......@@ -34,21 +33,14 @@ public class AwCrashReporterClient {
@VisibleForTesting
@CalledByNative
public static boolean stackTraceContainsWebViewCode(Throwable t) {
ClassLoader webViewClassLoader = AwCrashReporterClient.class.getClassLoader();
for (StackTraceElement frame : t.getStackTrace()) {
if (frame.getClassName().startsWith("android.webkit.")) {
if (frame.getClassName().startsWith("android.webkit.")
|| frame.getClassName().startsWith("com.android.webview.")
|| frame.getClassName().startsWith("org.chromium.")
|| (frame.getFileName() != null
&& frame.getFileName().startsWith(CHROMIUM_PREFIX))) {
return true;
}
if (frame.getFileName() != null && frame.getFileName().startsWith(DYNAMITE_PREFIX)) {
continue;
}
try {
Class frameClass = webViewClassLoader.loadClass(frame.getClassName());
if (frameClass.getClassLoader() == webViewClassLoader) {
return true;
}
} catch (ClassNotFoundException e) {
}
}
return false;
}
......
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