Skip to content

Commit

Permalink
Fixing WebView ProGuard config for annotations
Browse files Browse the repository at this point in the history
WebView used to not -keep its annotations. Thus, when trying to do
anything useful with ProGuard, it appeared that the annotations were not
being obeyed, since ProGuard had already stripped them out.

Note - since we still have the -keepnames class *** { *; }, this effectively
prevents any real optimizations from being run.

This change brings the .dex size down 7356 B, and removes 12 types, 5 fields,
and 57 strings. However, these all seem inconsequential, as this is the
method/class diff of this change:

org.chromium.base.Log
-  void d(java.lang.String,java.lang.String,java.lang.Object)
-  void v(java.lang.String,java.lang.String)
-  void d(java.lang.String,java.lang.String,java.lang.Object,java.lang.Object,java.lang.Object)
-  java.lang.String formatLogWithStack(java.lang.String,java.lang.Object[])
-  void d(java.lang.String,java.lang.String)
-  void v(java.lang.String,java.lang.String,java.lang.Object,java.lang.Object,java.lang.Object)
-  void <init>()
-  void d(java.lang.String,java.lang.String,java.lang.Object,java.lang.Object)
-  java.lang.String getCallOrigin()
-  void debug(java.lang.String,java.lang.String,java.lang.Object[])
-  void verbose(java.lang.String,java.lang.String,java.lang.Object[])

BUG=541543,583143,624827,627139

Review-Url: https://codereview.chromium.org/2147743002
Cr-Commit-Position: refs/heads/master@{#405491}
  • Loading branch information
smaier authored and Commit bot committed Jul 14, 2016
1 parent 7827029 commit 6eff9fc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions android_webview/apk/java/proguard.flags
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

# Keep all runtime visible annotations.
-keepattributes RuntimeVisibleAnnotations

# Disable optimization as this causes proguard to remove seemingly random stuff,
# including things explicitly kept in this configuration.
-dontoptimize
# Keeping annotations - if we remove these keeps, ProGuard will eliminate the
# annotations themselves, which will prevent them from affecting ProGuard's
# optimization run.
-keep @interface **.AccessedByNative
-keep @interface **.CalledByNative
-keep @interface **.CalledByNativeUnchecked
-keep @interface **.RemovableInRelease
-keep @interface **.UsedByReflection

# Keep the factory and its public members; it's the main entry point used by the
# framework.
Expand Down Expand Up @@ -39,11 +43,19 @@
native <methods>;
}

# Keep things explicitly marked as used by reflection
# Keep classes marked as used by reflection
-keep @**.UsedByReflection class com.android.webview.chromium.**,org.chromium.**

# Keep members explicitly marked as used by reflection
-keepclasseswithmembers class com.android.webview.chromium.**,org.chromium.** {
@**.UsedByReflection *;
}

# Remove methods annotated with this if their return value is unused
-assumenosideeffects class ** {
@org.chromium.base.annotations.RemovableInRelease <methods>;
}

# Linker dynamically casts to $TestRunner when running tests. We don't run these
# tests in WebView.
-dontnote org.chromium.base.library_loader.Linker$TestRunner
Expand Down

0 comments on commit 6eff9fc

Please sign in to comment.