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

[aw] Avoid treating dynamite proguarded class names as WebView.

When we determine whether a stack frame refers to WebView we look up the
class by name in the WebView classloader. If dynamite module code used
by the app has been proguarded, then it's possible for there to be a
class name collision, which causes us to treat it as a WebView class.

We can avoid this case specifically by relying on the fact that GMS
proguarding sets the source filename to a predictable value.

Bug: 1043656
Change-Id: Icff4d7eb931d8295902cdda2483da2578f071cd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2014445Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Tobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733969}
parent 3ca69fa3
......@@ -14,6 +14,11 @@ 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";
/**
* Determine if a Throwable should be reported to the crash reporting mechanism.
*
......@@ -31,10 +36,15 @@ public class AwCrashReporterClient {
public static boolean stackTraceContainsWebViewCode(Throwable t) {
ClassLoader webViewClassLoader = AwCrashReporterClient.class.getClassLoader();
for (StackTraceElement frame : t.getStackTrace()) {
if (frame.getClassName().startsWith("android.webkit.")) {
return true;
}
if (frame.getFileName().startsWith(DYNAMITE_PREFIX)) {
continue;
}
try {
Class frameClass = webViewClassLoader.loadClass(frame.getClassName());
if (frameClass.getClassLoader() == webViewClassLoader
|| frameClass.getPackage().getName().equals("android.webkit")) {
if (frameClass.getClassLoader() == webViewClassLoader) {
return true;
}
} catch (ClassNotFoundException e) {
......
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