pwa-builder / PWABuilder

The simplest way to create progressive web apps across platforms and devices. Start here. This repo is home to several projects in the PWABuilder family of tools.
https://docs.pwabuilder.com
Other
2.75k stars 284 forks source link

Image size is necessary but not sufficient for choosing images #3559

Open johncrim opened 2 years ago

johncrim commented 2 years ago

Tell us about your feature idea

The current approach for selecting icons is quite unwieldy because of the over-reliance on image sizes as a proxy for "where and how the image is used". This is true both for browsers and for PWABuilder, but it's a bigger problem for PWABuilder because of the number of image sizes that PWABuilder wants; and as the number of images grows the likelihood of mismatching grows significantly.

In other words, the problem is that art direction can't be specified by image size. I'm running into a lot of conflicts (eg my 150x150 med live tile icon keeps getting used as the "general icon" for my app, when it's not designed for that). I don't know why the 150x150 live tile icon is chosen, but both Chrome and Chromium Edge seem to like that size.

Here's another specific problem just from the windows images page:

What if my design for a splash screen is different from my design for a wide tile? Currently there's no way to resolve this.

In reality I'm running into many more conflicts than just these.

Another example is that I want background-less icons for task bar icons, but I want a background for live tile icons. The sizes overlap. How do I specify which is which?

With the current approach, art direction is a frustrating loop of trial and error, and settling for a tolerable compromise.

Do you have an implementation or a solution in mind?

It seems to me there are 2 problems:

  1. The information needed for PWABuilder to select the right icons to build packages for the Windows, Play, and Apple stores is a superset of what browsers need for basic PWA support (at a minimum, the set of images is much larger). Eg browsers support SVG favicons (which give us some nice features and cut down on the number of image files), but different OSes may need an extensive set of files.

  2. Image size is not sufficient for choosing the image the developer intended, especially when different browsers and tools have different requirements and algorithms for choosing fallback images.

The solutions I would like to see are:

  1. Add support for a PWABuilder-specific file that acts like a manifest extension for PWABuilder's use only. That way developers can populate the manifest with settings that are used by User-Agents, and they can optionally add PWABuilder specific info in another file (eg pwabuilder.manifest). That file could either be hosted at a well-known URL, or could be uploaded when running PWABuilder. This provides the benefit that run-time behavior isn't affected by the needs of PWABuilder.

If the file doesn't exist, the regular PWA manifest is used. If the file exists, it is merged with the PWA manifest before PWABuilder operates on it.

  1. It seems to me that the purpose field should be extended with new values that can be used by PWABuilder. For example, mstile-square, mstile-wide, splash-screen, task-bar, favicon, desktop in addition to standard values like maskable, monochrome. The alternative is a new field.

The purpose field (or a new field if that seems better) would trump any size information when selecting an image. If the combined manifests don't have a value for a given purpose (eg mstile-square), then PWABuilder falls back on the current size-based logic (which I've spent the last few days unsuccessfully trying to reverse engineer) for choosing an image.

The purpose field also has the benefit that unrecognized values are ignored, per the spec.

Have you considered any alternatives?

The alternative that I see is to use PWA Builder to generate some output from a small set of images, and then unpackage all the store package files and manually perform image selection for each of them, and package them back up.

PWABuilder is a very useful tool on the whole - I appreciate the work and maintenance that has gone into it.

ghost commented 2 years ago

Thanks for submitting a new feature request! I've automatically added a vote 👍 reaction to help get things started. Other community members can vote to help us prioritize this feature in the future.

ghost commented 2 years ago

This issue has been marked as "needs attention 👋" since it has not been triaged for 7 days. Please triage the issue .

ghost commented 1 year ago

This issue has been marked as "needs attention 👋" since it has not been triaged for 7 days. Please triage the issue .

johncrim commented 1 year ago

Here's the related stack overflow Q & As: https://stackoverflow.com/a/74059293/605067