Issue metadata
Sign in to add a comment
|
Use a whitelist to reduce the size of onResourceLoaded() in Monochrome |
||||||||||||||||||||||
Issue description1. ChromePublic.apk has a lot of resources, but doesn't require an onResourceLoaded() 2. WebView.apk has a small number of resources, and does require onResourceLoaded(). 3. MonochromePublic.apk currently does the worst of both: it has an onResourceLoaded() for the union on all resources. Idea: Use the R.txt file produced from resources that are descendants of //android_webview/glue:glue as a whitelist of resources to make non-final within R.java. We could perhaps also consider changing generate_resource_rewriter() to do this as well (e.g., have it spit out a whitelist as an output in addition to a .java file that calls onResourceLoaded()) Having a small onResourceLoaded should result in a dex size win as well as a start-up time win.
,
Feb 15 2017
Proguard has no concept of webview-reachable vs chrome-reachable, so I don't think we could.
,
Feb 15 2017
One thing I can't remember is that if Android platform requires or assumes all resources's package ID be changed, if so we have to change the package id for all resources of Monochrome even they are not actually used, otherwise it might conflicts with application's resources.
,
Feb 15 2017
re #3 - this doesn't apply to the ids as they exist within resources.arsc. This applies only to the generated .java code. So, I don't see how this could affect anything external to our apk.
,
Feb 15 2017
OK, I may not understand how the new way works
,
Apr 10 2017
,
Apr 10 2017
,
Apr 24 2017
,
May 9 2017
,
Jun 7 2017
Here is what webview's ./gen/android_webview/glue/glue_resource_rewriter.srcjar looks like:
public static void rewriteRValues(final int packageId) {
org.chromium.android_webview.R.onResourcesLoaded(packageId);
org.chromium.components.web_contents_delegate_android.R.onResourcesLoaded(packageId);
org.chromium.content.R.onResourcesLoaded(packageId);
android.support.v7.mediarouter.R.onResourcesLoaded(packageId);
org.chromium.ui.R.onResourcesLoaded(packageId);
org.chromium.media.R.onResourcesLoaded(packageId);
org.chromium.components.autofill.R.onResourcesLoaded(packageId);
com.google.android.gms.R.onResourcesLoaded(packageId);
android.support.v7.appcompat.R.onResourcesLoaded(packageId);
}
One notable here is the inclusion of appcompat, which I wouldn't have expected. Looks like it's due to a single call to AppCompatResources.getDrawable() in ui_java:
https://cs.chromium.org/chromium/src/ui/android/java/src/org/chromium/ui/DropdownAdapter.java?type=cs&q=android.support+file:%5Esrc/ui/android/java/+package:%5Echromium$&l=10
The addition of play services for webview also adds a lot of resources (and thus IDs that are re-written, 99% of which are unused).
Looking at .proguard.jar.usage files, it does appear that proguard removes the unused onResourcesLoadeded() calls and inlines IDs for the R classes not listed in rewriteRValues. So... I don't think there's anything that can be done here in terms of whitelisting until we figure out proper unused resource removal (bug 636448). If we had that, then we would know which support resources are used only by webview and not chrome, and use non-final IDs only for these.
,
Jun 7 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 15
This got implemented. |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by michaelbai@chromium.org
, Feb 15 2017