Bug 1529557 - Mutate share drawable to prevent against it being reused from cache; r=VladBaicu a=RyanVM
authorPetru Lingurar <petru.lingurar@softvision.ro>
Thu, 11 Jul 2019 23:15:30 +0300
changeset 541436 345b3f7685faf0fa46b568e34a5d2baf9e92cae0
parent 541435 18ed4493aa99009f084e2ee606fdc73f6ddffe92
child 541437 067e54510790223f29c1c10d8f488e10d679ae6c
push id11607
push usernerli@mozilla.com
push dateThu, 18 Jul 2019 14:12:34 +0000
treeherdermozilla-beta@067e54510790 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu, RyanVM
Bug 1529557 - Mutate share drawable to prevent against it being reused from cache; r=VladBaicu a=RyanVM Summary: The share drawable is used in multiple places in code. Android would cache it and subsequently serve a now dirty version of it with transformations potentially added. By mutating it into a new drawable we ensure we'll always have it clean. Reviewers: VladBaicu Reviewed By: VladBaicu Subscribers: emilio Bug #: 1529557 Differential Revision: https://phabricator.services.mozilla.com/D37734
--- a/mobile/android/base/java/org/mozilla/gecko/menu/MenuItemSwitcherLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/menu/MenuItemSwitcherLayout.java
@@ -4,19 +4,21 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 package org.mozilla.gecko.menu;
 import java.util.ArrayList;
 import java.util.List;
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.util.BitmapUtils;
 import android.annotation.TargetApi;
 import android.content.Context;
+import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
@@ -113,16 +115,19 @@ public class MenuItemSwitcherLayout exte
     public void setShowIcon(boolean show) {
     public void setIcon(Drawable icon) {
+        // Speculative prevention against drawable being referenced in some other parts of the code
+        // and so it being reused from cache with potentially unneeded transformations.
+        icon = new BitmapDrawable(BitmapUtils.getBitmapFromDrawable(icon));
     public void setIcon(int icon) {