Closed Bug 897772 Opened 11 years ago Closed 11 years ago

[fig] "Add to Home Screen" shortcut doesn't have an icon

Categories

(Firefox for Android Graveyard :: General, defect, P1)

All
Android
defect

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 26

People

(Reporter: Margaret, Assigned: Margaret)

References

Details

Attachments

(2 files)

In HomeContextMenuInfo, we're assuming the cursor always has a favicon, and using that to create the homescreen shortcut. However, the cursor doesn't always have a favicon.
Attached patch patchSplinter Review
Now that we use FaviconsLoader to lazily load the favicons for all the HomeListViews, we never have a Combined.FAVICONS column in the cursor for the list. Luckily, because FaviconsLoader caches the images, we can just pull them out of the cache (since this is a context menu, we know that the image must be loaded for the item the user is long tapping on).
Assignee: nobody → margaret.leibovic
Attachment #789286 - Flags: review?(wjohnston)
Comment on attachment 789286 [details] [diff] [review]
patch

Review of attachment 789286 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/home/HomeFragment.java
@@ +112,5 @@
>                      break;
>                  }
>  
> +                // The favicon should be in the cache because we're using a FavionsLoader to load the icon.
> +                Bitmap bitmap = Favicons.getInstance().getFaviconFromMemCache(info.url);

Is there a reason we wouldn't want to call Favicons.loadFavicon() and pass in the callback here instead?
Attachment #789286 - Flags: review?(wjohnston)
(In reply to Wesley Johnston (:wesj) from comment #2)
> Comment on attachment 789286 [details] [diff] [review]
> patch
> 
> Review of attachment 789286 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: mobile/android/base/home/HomeFragment.java
> @@ +112,5 @@
> >                      break;
> >                  }
> >  
> > +                // The favicon should be in the cache because we're using a FavionsLoader to load the icon.
> > +                Bitmap bitmap = Favicons.getInstance().getFaviconFromMemCache(info.url);
> 
> Is there a reason we wouldn't want to call Favicons.loadFavicon() and pass
> in the callback here instead?

To do that, we'd need to get the favicon URL (right now we only have the page URL). Favicons does have a method to do that, but it has to query the DB. If we're confident that the image will be in the cache, I think it would be smarter to save ourselves from this extra work.

The cache is 1MB:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/Favicons.java#69

So we would need to have loaded over 1MB worth of favicons since the icon in the menu item was last loaded. Since the icon will be drawn in the row that triggers the context menu, I am pretty confident it will be in the cache. Do you see a case where it might not be?
lucar's comment about the cache in bug 905685 makes me worried that this approach isn't actually as robust as I had hoped. However, maybe it will be once that bug is fixed.
Priority: -- → P1
Updating summary, since this always happens now.
Summary: [fig] "Add to Home Screen" shortcut doesn't have an icon sometimes → [fig] "Add to Home Screen" shortcut doesn't have an icon
Attached patch alternate patchSplinter Review
This actually goes through the loadFavicon dance to get the favicon. I decided to create a AddToLauncherTask class, to match the pattern we're already using for RemoveBookmarkTask and RemoveHistoryTask.
Attachment #791483 - Flags: review?(wjohnston)
Comment on attachment 791483 [details] [diff] [review]
alternate patch

Review of attachment 791483 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/home/HomeFragment.java
@@ -112,5 @@
> -            // FIXME: bug 897772
> -            Bitmap bitmap = null;
> -            if (info.favicon != null) {
> -                bitmap = BitmapUtils.decodeByteArray(info.favicon);
> -            }

I wonder if its worth leaving this in and fast pathing if we can? i.e.

if (info.favicon == null) {
  new AddToLauncherTask().execute();
  return true;
}
Attachment #791483 - Flags: review?(wjohnston) → review+
(In reply to Wesley Johnston (:wesj) from comment #7)
> Comment on attachment 791483 [details] [diff] [review]
> alternate patch
> 
> Review of attachment 791483 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: mobile/android/base/home/HomeFragment.java
> @@ -112,5 @@
> > -            // FIXME: bug 897772
> > -            Bitmap bitmap = null;
> > -            if (info.favicon != null) {
> > -                bitmap = BitmapUtils.decodeByteArray(info.favicon);
> > -            }
> 
> I wonder if its worth leaving this in and fast pathing if we can? i.e.
> 
> if (info.favicon == null) {
>   new AddToLauncherTask().execute();
>   return true;
> }

I'm not sure what you're getting at here... info.favicon is always null now, since the cursors we're using never have favicons stored in them, so there's not really any point to us using that for a check.
tracking-fennec: --- → ?
Hardware: ARM → All
https://hg.mozilla.org/mozilla-central/rev/26b37a40d65f
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 26
tracking-fennec: ? → ---
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: