New issue
Advanced search Search tips

Issue 890317 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 1
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

ImageView appears empty if LayerDrawable is mutated inside it

Project Member Reported by bsazonov@chromium.org, Sep 28

Issue description

Writing this down for posterity. Hit this during migration to AppCompatImageView: https://chromium-review.googlesource.com/c/chromium/src/+/1245786/3/chrome/android/java/res/layout/contextual_suggestions_card_modern.xml#103.

Repro steps:
1. Add imageView to the layout.
2. imageView.setImageDrawable(layerDrawable); // works fine with BitmapDrawable
3. layerDrawable.mutate();
Result: imageView shows up empty.

It turns out that this is caused by faulty LayerDrawable.mutate() implementation in KitKat - it wasn't copying bounds from old child drawables. It got fixed in Lollipop: https://android.googlesource.com/platform/frameworks/base/+/d7853e576301bf68e96148a0b9e52085bfc7cf95.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Sep 28

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

commit 195956610f109143b50d75992d4f65f5cc74a420
Author: Boris Sazonov <bsazonov@chromium.org>
Date: Fri Sep 28 18:21:43 2018

[Android] Implement LayerDrawableCompat and createLayerDrawable

This CL adds ApiCompatibilityUtils.createLayerDrawable and
LayerDrawableCompat. createLayerDrawable creates LayerDrawableCompat on
Android K and earlier versions and falls back to regular LayerDrawable
on newer versions. LayerDrawableCompat overrides mutate() method to work
around an issue in LayerDrawable.mutate() when the bounds of child
drawables aren't properly copied during the mutation. This issue would
force ImageView to appear empty if it contains a LayerDrawable and this
drawable is mutated.

Bug:  890317 
Change-Id: I3479a304917df1873645ccfda7102475981eff5b
Reviewed-on: https://chromium-review.googlesource.com/1251544
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595161}
[modify] https://crrev.com/195956610f109143b50d75992d4f65f5cc74a420/base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java
[modify] https://crrev.com/195956610f109143b50d75992d4f65f5cc74a420/chrome/android/java/src/org/chromium/chrome/browser/suggestions/ThumbnailGradient.java
[modify] https://crrev.com/195956610f109143b50d75992d4f65f5cc74a420/chrome/android/java/src/org/chromium/chrome/browser/widget/PromoDialog.java
[modify] https://crrev.com/195956610f109143b50d75992d4f65f5cc74a420/chrome/android/java/src/org/chromium/chrome/browser/widget/ViewHighlighter.java

Status: Fixed (was: Started)

Sign in to add a comment