New issue
Advanced search Search tips

Issue 923956 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Task



Sign in to add a comment

Get Resource identifier in AndroidProtocolHandler using Resource.getIdentifier(..) instead of class reflection to find R class

Project Member Reported by hazems@chromium.org, Yesterday (32 hours ago)

Issue description

I forked AndroidProtocolHandler[1] as AssetHelper in Android Support Library in CL[2] and then used it in the new lib in CL[3]. In a demo app CL[4] to show-case/test the new APIs, finding the R class using reflection was failing. torne@ suggested that it might be caused by proguard which removes the R class from the final APK for optimization. However, when Resources.getIdentifier(...) is used, it worked perfectly.

This task is to discuss whether we should consider using Resources.getIdentifier(...) in AndroidProtocolHandler in WebView as well. It should be lighter than reflection (if it's not optimized by the compiler). It would also resolve the package name not matching issue that the removeOneSuffix() is a partial workaround for, and might expose if there's any apps for which getIdentifier doesn't work. We could record a UMA stat for whether it had to fall back to reflection.

[1] https://cs.chromium.org/chromium/src/android_webview/java/src/org/chromium/android_webview/AndroidProtocolHandler.java
[2] https://android-review.googlesource.com/c/platform/frameworks/support/+/866991/
[3] https://android-review.googlesource.com/c/platform/frameworks/support/+/835923/
[4] https://android-review.googlesource.com/c/platform/frameworks/support/+/870579/
 

Comment 1 by hazems@chromium.org, Yesterday (32 hours ago)

Description: Show this description

Comment 2 by hazems@chromium.org, Today (20 hours ago)

Description: Show this description

Sign in to add a comment