Ensure all WebView Support Library utility is kept when proguarding webview/chrome |
||||
Issue descriptionWe might need to use @UsedByReflection on stuff in webview that's used by the support library (but not otherwise) to avoid those classes/fields/methods being removed by proguard. We should explicitly test that all the things we need are kept when proguarding.
,
Feb 14 2018
,
Feb 15 2018
I think the things we have to protect from proguard are: 1. boundary interfaces 2. boundary adapters - these use, or are used by, InvocationHandler, meaning their method signatures should be the same as the boundary interfaces'. 3. the entry-point for reflection into the support library glue layer (SupportLibReflectionUtil.createWebViewProviderFactory()).
,
Feb 27 2018
Hey Andrew, do you know if there's some nice way to add proguard rules for a directory / package without the use of @UsedByReflection? For context: we have a directory (https://cs.chromium.org/chromium/src/android_webview/support_library/boundary_interfaces/) which is shared between chromium and the Android Support Library, so we cannot depend on @UsedByReflection in that directory since that annotation lives in base (and isn't included into the Android Support Library). Note to self: we probably want to move all boundary adapters (in both the support library and chromium) to their own specific packages/directories so it's easier to create a proguard rule for them.
,
Feb 27 2018
You can use:
proguard_configs = [ "myproguard.flags" ]
on any java_library / android_library target, and it will get included in the proguard run for final apks.
So, you could just do:
-keep org.chromium.support_lib_boundary.** { * }
Or, you could create your own UsedByReflection annotation, and include a rule for it.
,
Feb 28 2018
Thanks Andrew! I think the easiest way to do this is keep everything in org.chromium.support_lib_boundary - the only class that is allowed to be proguarded is BoundaryInterfaceReflectionUtil, so I could just move that to its own util package.. (in case we want to add more things to that util package in the future).
So we would
-keep org.chromium.support_lib_boundary.* { * }
and move BoundaryInterfaceReflectionUtil to org.chromium.support_lib_boundary.util
In that way everything added to org.chromium.support_lib_boundary will be guarded against code obfuscation, while everything in org.chromium.support_lib_boundary.util will be open to code obfuscation.
,
Mar 5 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/0a6e992e64dcf503e038e34a0c7952172b29d9a9 commit 0a6e992e64dcf503e038e34a0c7952172b29d9a9 Author: Gustav Sennton <gsennton@google.com> Date: Mon Mar 05 10:23:12 2018 [android_webview] Save boundary interfaces from proguard obfuscation We need to keep the names of all boundary interface classes and methods used by the support library and chromium to ensure their names are the same in the support library as in the WebView APK. However, utility classes in the boundary interface package can be obfuscated just fine since they are not part of the boundary interface API. Ideally then, we will put everything that is part of the boundary interface API in one specific package, and keep utility methods in a sub-package, to allow for simple proguard rules (and avoid bugs where we incorrectly keep/remove new boundary interfaces). Bug: 809471 Change-Id: I7a700fcc50998d83bf3bfa799196477289bedb3e Reviewed-on: https://chromium-review.googlesource.com/943504 Reviewed-by: agrieve <agrieve@chromium.org> Reviewed-by: Richard Coles <torne@chromium.org> Commit-Queue: Gustav Sennton <gsennton@chromium.org> Cr-Commit-Position: refs/heads/master@{#540800} [modify] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/boundary_interfaces/BUILD.gn [add] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/boundary_interfaces/proguard.flags [rename] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/boundary_interfaces/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java [modify] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibReflectionUtil.java [modify] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebViewChromium.java [modify] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebViewChromiumFactory.java [modify] https://crrev.com/0a6e992e64dcf503e038e34a0c7952172b29d9a9/android_webview/support_library/java/src/org/chromium/support_lib_glue/SupportLibWebkitToCompatConverterAdapter.java
,
Mar 5 2018
The chromium part of this is now solved. The Android support library side is tracked in b/74181771 |
||||
►
Sign in to add a comment |
||||
Comment 1 by sbash...@chromium.org
, Feb 7 2018