0

Reland "R8: Enabling horizontal class merging"

This is a reland of commit 61b4cec522

Locally, I confirmed that we are now not removing any extra resources,
which should mean that this will not cause the same issue as it did
before.

Original change's description:
> R8: Enabling horizontal class merging
>
> We've forgotten to turn on horizontal class merging since landing the
> presumed fix to the perforance regressions here:
> https://chromium-review.googlesource.com/c/chromium/src/+/3564699
>
> Bug: 1173182
> Change-Id: Ief2578c89f8819bed7789480e5eee35c98f29292
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3787687
> Commit-Queue: Andrew Grieve <agrieve@chromium.org>
> Auto-Submit: Sam Maier <smaier@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Commit-Queue: Sam Maier <smaier@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1028915}

Bug: 1173182, 1348329
Change-Id: I16f274a45c935958f42e0d07e84c605a53d98c6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3806226
Auto-Submit: Sam Maier <smaier@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Commit-Queue: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1031484}
This commit is contained in:
Sam Maier
2022-08-04 13:58:53 +00:00
committed by Chromium LUCI CQ
parent 99561d64c9
commit c66dad831a
3 changed files with 18 additions and 1 deletions
android_webview/nonembedded/java
build/android/gyp
chrome/android/expectations

@ -34,6 +34,15 @@
public *;
}
# This rule prevents class merging on R$* resource classes (for example, R$anim,
# R$styleable, R$bool). This causes issues for WebView when unused resource
# stripping, since in WebView we are forced to detect which resources are unused
# by scanning the dex file for R$<res_type>.<res_name>. Having the R$* classes
# being merged together means that R$anim.foo may now be found in R$bool.foo,
# and this mistakenly will mark the foo resouce to be removed. More details in
# crbug.com/1348329.
-keep,allowaccessmodification,allowobfuscation,allowshrinking class **.R$*
# Functor classes with native methods implemented in Android.
-keep class com.android.webview.chromium.DrawFunctor
-keep class com.android.webview.chromium.DrawGLFunctor

@ -289,7 +289,6 @@ def _OptimizeWithR8(options,
# R8 OOMs with the default xmx=1G.
cmd = build_utils.JavaCmd(options.warnings_as_errors, xmx='2G') + [
'-Dcom.android.tools.r8.experimental.enablewhyareyounotinlining=1',
'-Dcom.android.tools.r8.disableHorizontalClassMerging=1',
]
if options.dump_inputs:
cmd += ['-Dcom.android.tools.r8.dumpinputtofile=r8inputs.zip']

@ -416,6 +416,15 @@
public *;
}
# This rule prevents class merging on R$* resource classes (for example, R$anim,
# R$styleable, R$bool). This causes issues for WebView when unused resource
# stripping, since in WebView we are forced to detect which resources are unused
# by scanning the dex file for R$<res_type>.<res_name>. Having the R$* classes
# being merged together means that R$anim.foo may now be found in R$bool.foo,
# and this mistakenly will mark the foo resouce to be removed. More details in
# crbug.com/1348329.
-keep,allowaccessmodification,allowobfuscation,allowshrinking class **.R$*
# Functor classes with native methods implemented in Android.
-keep class com.android.webview.chromium.DrawFunctor
-keep class com.android.webview.chromium.DrawGLFunctor