-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-plugin-manifest] Default favicon set doesn't render well (Firefox, retina display) #19899
Comments
Strange that adding a lower resolution image fixes this. Have you found any information on why this fixes the problem? |
My original description of "looks low-res" isn't a good one actually. "Jagged" is a much better way to put it: it's from poor downscaling rather than upscaling (eg. some kind of nearest-neighbour thing going on). 16x16: that classic "blurry" appearance of low-res being scaled up 32x32: lovely 48x48: jagged 512x512: more jagged still As for why 32x32 is the fix: I didn't find any sort of official spec from Mozilla on 32x32 being preferred. It's pretty empirical, just inspected the favicon loading for a few sites in the wild. Github, Gitlab, Stack Overflow, MDN all look sharp, and they all load a 32x32 favicon. Some are png, some are ico, so the format doesn't seem to matter. Wikipedia, Gatsby's own site and Amazon have that jagged appearance, and a 48x48 icon. Interestingly (depending on what kind of things you find interesting 😄) the icons in the address bar suggestions seem to get downscaled perfectly fine. It's just the icon in the tab itself. So I imagine Firefox will fix this from their end one day (but after trying out their nightly build, that day has not come yet). I'll look into opening a bug with Firefox if one doesn't exist already. So I guess the question is whether there's a downside to including the 32x32 to work around this. |
thanks for the detailed information. I did a quick look and learned you can actually have multiple icon tags with different sizes. https://www.emergeinteractive.com/insights/detail/The-Essentials-of-FavIcons/ Right now the "favicon" support in the plugin just takes the smallest icon passed in and uses it for the favicon. If we want to fix this the better option would probably to have it scale that to 32x32 or add multiple tags with different size favicons. Upon further review it seems the "sizes" property on rel="icon" is not actually supported in any browser. so Generating a 32px size may be the best option. It seems it'd be ideal if the icon was in the "ico" format to containing 16, 32, and 48 pixel sizes, but alas sharp doesn't support that. Resources: |
This is definitely a bit of a rabbit hole. Real Favicon Generator even goes as far as adding in extra image processing steps to make sure iOS/Android homescreen icons have solid backgrounds and appropriate padding, etc. After reading a bit more, the important points to me are:
Since <link rel="icon" href="/icons/icon-32x32.png">
<link rel="icon" href="/icons/icon-16x16.png"> Sounds like you agree?
[1] 32 is described here as "standard for most desktop browsers". Real Favicon Generator only includes 16 and 32 resolutions for the PNG favicons. For reference, an example of Real Favicon Generator's HTML output: <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff"> |
and here's a screen shot of how the icon gets generated when being saved to home screen. |
@lifeiscontent Is this what you'd expect? Did you have a question? I don't mean to be rude, just trying to understand. |
@cycleseven I agree we should probably scale it back to 32px. I see clear indications from spec that the |
@moonmeister hey, thanks for your reply. If you look at the link I send below the image, the source image is square as required by the gatsby favicon feature if I use a PNG instead of an SVG it results in a correct image output. So the issue is when going from PNG to PNG it is correct, but when going from SVG to PNG it produces undesired results. |
@lifeiscontent I still don't fully understand the issue. From the sound of it, this is related to manifest icons and not the favicon, more specifically the conversion of SVGs. I'd suggest opening your own issue and include a side by side screenshot of correct vs. incorrect. |
@moonmeister given this key in the gatsby config: if I put the same exact image (except an SVG version) the icons that are generated from gatsby are off-center and cut off from the bottom. the image processing (crop, position) should yield the same results I would assume. But they do not. after I update my code from an SVG to a PNG the results that got processed are now correct as you can see here: https://lifeiscontent.net/icons/icon-96x96.png?v=a5fe6232036f625a4049535fb204c378 however, if I used the SVG variant of the icon, it would be processed as I demonstrated in the previous screen shot of my phone. |
also I noticed when I give a transparent PNG as the source, the background is black, while if I give a transparent SVG it is white. so there are some really weird inconsistencies. I'd expect the background of the icon to be the color of or throw an error specifying that an icon needs to not be transparent. |
This comment has been minimized.
This comment has been minimized.
@moonmeister if there is any other information I can provide, please let me know, I'd love to help figure out how to move forward with this 👍 |
You're welcome to submit a PR. I may have time, I may not...Zombie apocalypse and all... |
@moonmeister can you point me to the code that might be relevant for a PR? I haven't contributed before. |
@lifeiscontent Alright, here is the link where we simply extract the first and theoretically smallest icon and use it for the favicon. In the |
Hey @moonmeister, the zombie apocalypse actually turned out to be a decent time for me to give a PR a shot 😄 (#23077). It's my first time attempting to contribute code to Gatsby, so imagine it will need some work. But maybe can get the ball rolling on this issue again at least. @lifeiscontent I also think your issue is different to my original one, I doubt this PR will help with it unfortunately. Maybe it's worth opening a separate issue for the SVG problem so it doesn't get lost? |
Published |
See gatsbyjs/gatsby#19899 (hopefully will lead to a long-term fix)
Description
When using the default favicon set produced by
gatsby-plugin-manifest
, the icon used by Firefox looks low-res (on my retina Macbook).Firefox
Chrome
Steps to reproduce
This affects any site using
gatsby-plugin-manifest
's automatic icon generation, including Gatsby's own. You could build that project to reproduce this.Expected result
Favicon looks sharp in both browsers.
Actual result
Favicon looks low-res in Firefox.
Environment
Proposed fix
Adding the 32x32px version to the default icons config fixes this, and looks good in other browsers I tested too (Chrome, Safari, iOS Safari).
Happy to submit a PR with this change, unless there's a known reason to avoid including the 32x32 resolution.
The text was updated successfully, but these errors were encountered: