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; ...@@ -14,10 +14,9 @@ import org.chromium.base.annotations.JNINamespace;
*/ */
@JNINamespace("android_webview") @JNINamespace("android_webview")
public class AwCrashReporterClient { public class AwCrashReporterClient {
// The filename prefix used by GMS proguarding, which we use to recognise // The filename prefix used by Chromium proguarding, which we use to
// otherwise colliding proguarded class names as belonging to dynamite // recognise stack frames that reference WebView.
// modules. private static final String CHROMIUM_PREFIX = "chromium-";
private static final String DYNAMITE_PREFIX = ":com.google.android.gms";
/** /**
* Determine if a Throwable should be reported to the crash reporting mechanism. * Determine if a Throwable should be reported to the crash reporting mechanism.
...@@ -34,21 +33,14 @@ public class AwCrashReporterClient { ...@@ -34,21 +33,14 @@ public class AwCrashReporterClient {
@VisibleForTesting @VisibleForTesting
@CalledByNative @CalledByNative
public static boolean stackTraceContainsWebViewCode(Throwable t) { public static boolean stackTraceContainsWebViewCode(Throwable t) {
ClassLoader webViewClassLoader = AwCrashReporterClient.class.getClassLoader();
for (StackTraceElement frame : t.getStackTrace()) { 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; 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; 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