New issue
Advanced search Search tips

Issue 879194 link

Starred by 1 user

Issue metadata

Status: Started
Owner:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Splash screen icon has different size on Android N & Android M

Project Member Reported by pkotw...@chromium.org, Aug 30

Issue description

Repro steps:
1) Get a Nexus 5x device running Android M, and another running Android N
2) Set the Chrome command line to --skip-webapk-verification on both devices
3) Install the attached WebAPK on both devices
4) Launch the WebAPK on both devices

Expected:
The splash screen on both devices looks identical
Actual:
The icon on the splash screen on the Android N device is larger than the icon on the splash screen on the Android M device
 
splash_marshmallow.png
27.1 KB View Download
splash_nougat.png
29.0 KB View Download
WebApk.apk
74.7 KB Download
Was this a framework bug that was fixed in N?
The Nexus 5x is an xxhdpi device.

WebApkInfo#create() calls
Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXHIGH) for the icon displayed in recents
Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXXHIGH) for the splash screen icon

If the WebAPK does not have an icon in mipmap-xxhdpi/ Resources#getDrawableForDensity() returns a scaled version of the icon in mipmap-xxxhdpi/
Up till Android M, there is a bug where if two calls to Resources#getDrawableForDensity() return an icon for the same resource id from the same mipmap-*dpi/ directory, the second call returns a cached icon scaled to the density specified for the first call.

If a WebAPK only provides an icon in mipmap-xxxhdpi/ with size 196x196 px, the following behavior occurs on Android versions up till M:
___________________________________________________________________________________________________________
Call order                                                                           | Returned bitmap size
_____________________________________________________________________________________|_____________________
#1 Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXHIGH)    | 129x129 density=420
#2 Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXXHIGH)   | 129x129 density=420
_____________________________________________________________________________________|_____________________
#1 Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXXHIGH)   | 196x196 density=420
#2 Resources#getDrawableForDensity("app_icon.png", DisplayMetrics.DENSITY_XXHIGH)    | 196x196 density=420

Status: Started (was: Assigned)
I suggest fixing this by calling a version of Resources#getDrawableForDensity() which does not do any scaling 
Thanks, seems reasonable then
Project Member

Comment 6 by bugdroid1@chromium.org, Sep 7

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/efa2830b6043cb649e5e5ad15112ad15518c8903

commit efa2830b6043cb649e5e5ad15112ad15518c8903
Author: Peter Kotwicz <pkotwicz@chromium.org>
Date: Fri Sep 07 21:37:07 2018

[Android WebAPK] Make splash icon have same size on Android <=M & N+

When resources for a screen density are missing in a WebAPK (e.g. the
WebAPK only contains an icon for xxxhdpi),
Resources#getDrawableForDensity() returns a scaled bitmap.

On Android versions up to Android M, Resources#getDrawableForDensity()
would sometimes return an incorrectly scaled cached bitmap instead of
rerequesting the resource and scaling it for the passed in density. See
the bug for more details.

This CL moves the icons to the mipmap-nodpi folder in order to disable
the automatic scaling when requesting a resource. The scaling now occurs
inside of ImageView. The move fixes the caching bug.

It also increases how often we use the webapp_splash_screen_no_icon.xml
layout on high density devices. In particular, if the WebAPK only has
a 144x144px sized icon on xxxhdpi devices:
Prior to this CL: We used webapp_splash_screen_small.xml and
                  upscaled the icon.
With this CL: We will use webapp_splash_screen_no_icon.xml

BUG=879194

Change-Id: I3c87898ca39cc7a47b614d4b219aee5f1e41ce74
Reviewed-on: https://chromium-review.googlesource.com/1199768
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589669}
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkInfo.java
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/libs/common/src/org/chromium/webapk/lib/common/WebApkMetaDataKeys.java
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/AndroidManifest.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/bound_manifest_config.json
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/javatest_manifest_config.json
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/maps_go_manifest_config.json
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/drawable-hdpi/splash_icon.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/drawable-mdpi/splash_icon.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/drawable-xhdpi/splash_icon.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/drawable-xxhdpi/splash_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/drawable-xxxhdpi/splash_icon.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-hdpi/app_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-hdpi/ic_launcher.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-mdpi/app_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-mdpi/ic_launcher.xml
[rename] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-nodpi/app_icon_hdpi.png
[rename] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-nodpi/app_icon_mdpi.png
[rename] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-nodpi/app_icon_xhdpi.png
[rename] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-nodpi/app_icon_xxhdpi.png
[rename] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-nodpi/app_icon_xxxhdpi.png
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xhdpi/app_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xhdpi/ic_launcher.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xxhdpi/app_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xxhdpi/ic_launcher.xml
[add] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xxxhdpi/app_icon.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/res/mipmap-xxxhdpi/ic_launcher.xml
[modify] https://crrev.com/efa2830b6043cb649e5e5ad15112ad15518c8903/chrome/android/webapk/shell_apk/unbound_manifest_config.json

Sign in to add a comment