New issue
Advanced search Search tips

Issue 627139 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Enable Proguard optimizations in WebView

Project Member Reported by smaier@chromium.org, Jul 11 2016

Issue description

As it stands, WebView's Proguard configuration is very relaxed, and doesn't do nearly as much as it could to trim waste off. The first step we'd like to take is to enable optimizations, as they are turned off for the entire .apk.

 
Project Member

Comment 1 by bugdroid1@chromium.org, Jul 12 2016

The following revision refers to this bug:
  https://chrome-internal.googlesource.com/clank/internal/apps/+/ceb05c37ac01c226b9146ac4f1c51f80a35c09c9

commit ceb05c37ac01c226b9146ac4f1c51f80a35c09c9
Author: Sam Maier <smaier@google.com>
Date: Mon Jul 11 18:48:27 2016

Comment 2 by smaier@chromium.org, Jul 14 2016

Cc: torne@chromium.org
I've looked into changing the -keepnames class *** { *; } line from WebView's proguard.flags.

Keeping the line as-is (with https://codereview.chromium.org/2147743002/) for system_webview_google_apk gives us:

1086108 .dex size
10066 methods
1847 types
3442 fields
11027 strings
105528 bytes of permanent dirty memory

Changing the line to -keepnames,allowoptimization class *** { *; } gives us:
1034148 .dex size
9414 methods
1764 types
3265 fields
10449 strings
99568 bytes of permanent dirty memory

Removing the line altogether (and thus, allowing obfuscation to take place) gives us:
938556 .dex size
9414 methods
1764 types
3265 fields
7303 strings
86984 bytes of permanent dirty memory

As for the stacktraces that come out of these changes, I think a WebView team member would be better suited to judge them. 

Comment 3 by torne@chromium.org, Jul 14 2016

Components: Mobile>WebView
Thanks for the data. Once you've landed the current CLs, I can try to take a look at this?
Project Member

Comment 4 by bugdroid1@chromium.org, Jul 14 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6eff9fcd9bce74c436c3ce33355f1b7acbcc3b34

commit 6eff9fcd9bce74c436c3ce33355f1b7acbcc3b34
Author: smaier <smaier@chromium.org>
Date: Thu Jul 14 14:36:22 2016

Fixing WebView ProGuard config for annotations

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}

[modify] https://crrev.com/6eff9fcd9bce74c436c3ce33355f1b7acbcc3b34/android_webview/apk/java/proguard.flags

Project Member

Comment 5 by bugdroid1@chromium.org, Aug 16 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0e0838f9baa10ec6382faf06ba37b6e1a6f80d6c

commit 0e0838f9baa10ec6382faf06ba37b6e1a6f80d6c
Author: smaier <smaier@chromium.org>
Date: Tue Aug 16 20:35:59 2016

Turning optimizations on for the bulk of webview

This shaves 85kb from the .dex size and 10kb from memory overhead.

BUG= 627139 

Review-Url: https://codereview.chromium.org/2240483002
Cr-Commit-Position: refs/heads/master@{#412329}

[modify] https://crrev.com/0e0838f9baa10ec6382faf06ba37b6e1a6f80d6c/android_webview/apk/java/proguard.flags

Comment 6 by smaier@chromium.org, Aug 18 2016

Status: Fixed (was: Untriaged)
Yesterday's commit officially turns this on.

Sign in to add a comment