New issue
Advanced search Search tips

Issue 692554 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 791078
Owner:
Closed: Oct 15
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocked on:
issue 636448



Sign in to add a comment

Use a whitelist to reduce the size of onResourceLoaded() in Monochrome

Project Member Reported by agrieve@chromium.org, Feb 15 2017

Issue description

1. 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.
 
Can we use proguard to remove the unnecessary onResourceLoaded()? 
Proguard has no concept of webview-reachable vs chrome-reachable, so I don't think we could.
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.
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.
OK, I may not understand how the new way works
Labels: Quick-Win
Labels: intern

Comment 8 by zpeng@chromium.org, Apr 24 2017

Owner: ----
Status: Available (was: Assigned)
Labels: -binary-size Performance-Size
Blockedon: 636448
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.
Project Member

Comment 11 by sheriffbot@chromium.org, Jun 7 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
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
Mergedinto: 791078
Owner: mheikal@google.com
Status: Duplicate (was: Untriaged)
This got implemented.

Sign in to add a comment