When picking a favicon, pick the one with the shortest size difference
Categories
(Toolkit :: Places, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox133 | --- | fixed |
People
(Reporter: mak, Assigned: yazan)
References
(Blocks 4 open bugs, Regressed 2 open bugs)
Details
(Keywords: papercut, Whiteboard: [snt-scrubbed][places-papercut][favicons-2024])
User Story
Fix Bug 1772264 first, we must be able to distinguish rich favicons from others in the database. When serving "small-ish" icons (<= 64px), always filter our rich icons. This can be first part/revision here. Then among the remaining icons, when there's no perfect match, consider both the smaller and the larger ones. If the larger one is >= 200% the requested size, and the smaller is >= 50% the requested size, prefer the smaller ((size_requested - size_small) >= (size_big - size_requested) / 4) This second part is more complex and can be moved to a follow-up bug. See comment 7 for some code pointers.
Attachments
(1 file, 1 obsolete file)
Reporter | ||
Updated•6 years ago
|
Updated•6 years ago
|
Reporter | ||
Comment 1•5 years ago
|
||
and while we check the scaling factor, if it's just 2, we could still prefer the local favicon to the root one.
Comment 2•5 years ago
|
||
Do you think this would be a good first bug? If so could you tag it as such? Thanks!
Reporter | ||
Comment 3•5 years ago
|
||
It involves Cpp and complex SQL, plus some calculation, it could be mentored maybe, but it's not a good first one.
Comment 5•3 years ago
|
||
I just wanted to comment that this issue has been affecting my work.
I made a helpful example page with steps to reproduce the issue and verify it easily:
https://firefox-favicon-ico-size-bug-retina.netlify.app/
(Code on GitHub: https://github.com/wavebeem/firefox-favicon-ico-size-bug-retina)
Reporter | ||
Comment 6•3 years ago
|
||
yeah, there's a couple things we should do to improve favicons matching:
- annotate in the db if an icon is a rich one (apple-touch). When serving a favicon at common small sizes (16-64) prefer the non-rich ones
- when there's no perfect match, pick shortest size distance instead of the next larger one
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Reporter | ||
Comment 7•2 years ago
|
||
For the first part, identifying a rich icon and storing the info, you can look here
https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/browser/actors/LinkHandlerChild.jsm#112,115-118,130
then it goes through https://searchfox.org/mozilla-central/source/browser/modules/FaviconLoader.jsm that loads it in content
finally it is stored in the parent process https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/browser/actors/LinkHandlerParent.jsm#141-154
The storing is done through 2 APIs:
https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/browser/components/places/PlacesUIUtils.sys.mjs#226-231,234-241
the first one sets the icon in a memory cache, while the second one copies it from the memory cache into the database (why these are separate is an historical fact, we would like to change it in the future into a single API)
The storing process is async in cpp, an object is created (actually pulled from the memory cached) containing the icon info and passed to a runnable in the async thread
https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/toolkit/components/places/nsFaviconService.cpp#378,437-441
The icon is finally stored
https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/toolkit/components/places/FaviconHelpers.cpp#164,208-210,1050,1068
You'll have to add a new column to the icons table, there's an example in Bug 1776606. And then pass-through the rich information, and store it in this new rich
boolean column (that in practice is an integer column because in Sqlite bool is stored as a 0-sized int)
For the second part, the selection of which icon to return is done here:
https://searchfox.org/mozilla-central/rev/6f77213807eb5359c8afe458ac5628f973e92a25/toolkit/components/places/FaviconHelpers.cpp#388-408
It may be part SQL and part code, no obligation.
I'm happy to help with it, also on Zoom if you wish, or answer questions. This bug may be an interesting learning process.
Reporter | ||
Updated•7 months ago
|
Reporter | ||
Updated•6 months ago
|
Updated•6 months ago
|
Assignee | ||
Updated•4 months ago
|
Assignee | ||
Comment 8•4 months ago
|
||
Updated•4 months ago
|
Assignee | ||
Comment 9•4 months ago
|
||
Updated•4 months ago
|
Comment 10•3 months ago
|
||
Comment 11•3 months ago
|
||
bugherder |
Updated•2 months ago
|
Description
•