Bug 837373 - Check for valid favicon before scaling it. r=mfinkle a=akeybl
authorBrian Nicholson <bnicholson@mozilla.com>
Mon, 04 Feb 2013 11:08:10 -0800
changeset 127398 d97ded59975b5d12ca028e669d9980694ef3ce59
parent 127397 5e1d996af86214f505fd22a87aa679f86998c96a
child 127399 4c0a3876f71780df214f9b93fdea200cfb3de099
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle, akeybl
bugs837373
milestone20.0a2
Bug 837373 - Check for valid favicon before scaling it. r=mfinkle a=akeybl
mobile/android/base/Favicons.java
mobile/android/base/awesomebar/AllPagesTab.java
mobile/android/base/awesomebar/AwesomeBarTab.java
--- a/mobile/android/base/Favicons.java
+++ b/mobile/android/base/Favicons.java
@@ -310,17 +310,17 @@ public class Favicons {
             }
 
             if (isCancelled())
                 return null;
 
             String storedFaviconUrl = getFaviconUrlForPageUrl(mPageUrl);
             if (storedFaviconUrl != null && storedFaviconUrl.equals(mFaviconUrl)) {
                 image = loadFaviconFromDb();
-                if (image != null)
+                if (image != null && image.getWidth() > 0 && image.getHeight() > 0)
                     return scaleImage(image);
             }
 
             if (isCancelled())
                 return null;
 
             image = downloadFavicon(faviconUrl);
 
--- a/mobile/android/base/awesomebar/AllPagesTab.java
+++ b/mobile/android/base/awesomebar/AllPagesTab.java
@@ -804,17 +804,17 @@ public class AllPagesTab extends Awesome
 
             do {
                 final String url = c.getString(c.getColumnIndexOrThrow(Combined.URL));
                 final byte[] b = c.getBlob(c.getColumnIndexOrThrow(Combined.FAVICON));
                 if (b == null)
                     continue;
 
                 Bitmap favicon = BitmapFactory.decodeByteArray(b, 0, b.length);
-                if (favicon == null)
+                if (favicon == null || favicon.getWidth() <= 0 || favicon.getHeight() <= 0)
                     continue;
 
                 favicon = Favicons.getInstance().scaleImage(favicon);
                 Favicons.getInstance().putFaviconInMemCache(url, favicon);
             } while (c.moveToNext());
         } finally {
             if (c != null)
                 c.close();
--- a/mobile/android/base/awesomebar/AwesomeBarTab.java
+++ b/mobile/android/base/awesomebar/AwesomeBarTab.java
@@ -85,23 +85,24 @@ abstract public class AwesomeBarTab {
         if (mResources == null) {
             mResources = mContext.getResources();
         }
         return mResources;
     }
 
     protected void updateFavicon(ImageView faviconView, Cursor cursor) {
         byte[] b = cursor.getBlob(cursor.getColumnIndexOrThrow(URLColumns.FAVICON));
-        if (b == null) {
-            faviconView.setImageDrawable(null);
-        } else {
+        Bitmap favicon = null;
+        if (b != null) {
             Bitmap bitmap = BitmapFactory.decodeByteArray(b, 0, b.length);
-            bitmap = Favicons.getInstance().scaleImage(bitmap);
-            updateFavicon(faviconView, bitmap);
+            if (bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) {
+                favicon = Favicons.getInstance().scaleImage(bitmap);
+            }
         }
+        updateFavicon(faviconView, favicon);
     }
 
     protected void updateFavicon(ImageView faviconView, Bitmap bitmap) {
         if (bitmap == null) {
             faviconView.setImageDrawable(null);
         } else if (Favicons.getInstance().isLargeFavicon(bitmap)) {
             // If the icon is large, hide the background
             faviconView.setImageBitmap(bitmap);