Skip to content
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

Talk a bit more about app vs. tab? #1

Closed
domenic opened this issue Jul 4, 2018 · 17 comments
Closed

Talk a bit more about app vs. tab? #1

domenic opened this issue Jul 4, 2018 · 17 comments

Comments

@domenic
Copy link

domenic commented Jul 4, 2018

First of all, this is really cool!! I loved reading the proposal and seeing the care that went into coming up with something that was flexible and powerful, but also mapped to a wide variety of hosts.

One aspect that I found surprising was in the goals/non-goals section, about this being specifically an application-wide badge, instead of a per-tab badge. Partially this is because I have a lot of tabs today that implement their own badges using favicons or <title> changes.

Upon reflection, I think the restriction makes sense. (I can't think of any of the web apps I use which have different badge counts in different tabs; they all synchronize.) Still, it might be worth a dedicated section with a few paragraphs spelling out the problem space here and why being app-wide is the best solution.

I also would wonder if it's worth softening the non-goal

To provide badging for sites in a normal web browsing context. While it will be available to normal websites, user agents will generally not surface the badge unless the app is installed or has some presence in the operating system shelf area.

I think it'd be a bit of a shame for web developers if they had to continue using their favicon/<title> tricks, in addition to this API, to give users a good experience when used in a tab. It seems like, if you applied the badging to all tabs under a given application, it would be a win for the user and web developer.

If you're worried about collision with existing techniques, it could be opt-in, e.g. set(x, { evenWhenNotInstalled: true }).

This could greatly reduce the custom code web developers have to write to update their favicons/titles and synchronize across tabs.

@mgiuca
Copy link
Collaborator

mgiuca commented Jul 5, 2018

I think you're right. If we're going to have a badging API, we should be able to phase out favicon hacks with this. Though tabs require a bit more consideration than what I've got here. Some points:

  • Probably wouldn't want to always badge tabs for any site using this API. Might want to give a choice of whether to apply to tabs. (I wouldn't call it "even when not installed" because you can still run a site in tabs if it's installed; more of a choice of whether it applies to the per-window UI or just the per-app UI of the operating system, though these concepts are fuzzy and hard to define when we're not talking about any specific OS.)
  • Would we want to limit it to "all tabs show the same badge" or have some kind of per-tab badge? If so, it suggests a slightly different API that you call from the foreground pages, not a global API that can be called from a service worker.

I'll update the explainer to be less clear on this point. [Edit: Done; see "Possible areas for expansion".]

@domenic
Copy link
Author

domenic commented Jul 10, 2018

Yay!

Regarding per-tab badging, or some tabs not having a badge: although these ideas make sense in theory, in practice, surveying my current favicon/title-badged tabs, it seems like all tabs from the app would want the same badge.

Right now they all synchronize using the back-end server. I guess maybe they'd want different badges, if the contents of the tab were not synced correctly? E.g. you have two mail windows open, one has an unread message list with 4 unread messages, the other has an unread message list with 5 unread messages. Should they be badged with 4 and 5, respectively? Or should they just be badged with a single value, and the fact that their contents are not synced with their badge is a temporary glitch.

For the record, the tabs I'm considering that currently use favicon/title badges: IRCCloud, Twitter, Facebook Messenger, Google Chat, Google Hangouts, Gmail.

@mgiuca
Copy link
Collaborator

mgiuca commented Jul 11, 2018

You might also want different badges if you had different contexts in the same app. For example, (I don't use Slack so I'm not super sure how it works but...) Slack might have two completely different organizations which are open in different tabs, but share a service worker or origin. You might want to show individual unread counts for that tab's organization.

@marcoscaceres
Copy link
Member

Slack might have two completely different organizations which are open in different tabs, but share a service worker or origin.

Agree. I also run multiple gmails (marcos@marcosc and mcaceres@mozilla) in separate tabs.

@fallaciousreasoning
Copy link
Collaborator

Could also be useful for text editors (with a this file hasn't been saved badge) and Github pull requests (they display the status of the PR in the favicon).

That said, this is already possible through favicon hacks, maybe its worth providing a slightly more ergonomic API here instead of superseding it with this Badge API (which is going to have some pretty hard limitations because we have to conform with what's available on all supported platforms).

Maybe

<link rel="shortcut icon badge" href="/favicon.ico" badge="99">

or something.

As for badging different windows of apps in different ways, it'd be nice but I don't think there's really a way to display this on most platforms:

  • Windows: All windows are collapsed into a single tile. The most recent Badge will be shown. I think there's still an option somewhere to display each window in its own tile but it's not the default.
  • Mac: There's one dock icon for each app. Most recent Badge will be shown
  • Android/iOS/ChromeOS: There's a single icon in the launcher for each app. I imagine the most recent Badge is shown but can't confirm.

If we added a separate API for setting a per tab badge there'd be an opportunity for third party libraries to keep the badges in sync, if apps really want to do this.

@comp615
Copy link

comp615 commented Apr 17, 2019

Wanted to throw in some information from Twitter's time playing around with this...we do do those old favicon and title hacks on our old site. But on the new version we do not, and we've heard some users complaining that they can't tell when new content or notifications are available on Twitter. We'd love for this API to affect favicon as well as the app icon.

@marcoscaceres
Copy link
Member

That's a nice suggestion, particularly for desktop.

@fallaciousreasoning
Copy link
Collaborator

fallaciousreasoning commented Apr 23, 2019

This is a bit more complicated than it seems, the new badging API is doing something kind of different to what was being done with favicon hacks.

Favicons: One badge per instance of an app
Badging API: One badge per app

There are definitely some cases where it would be handy to treat badging both the same (e.g. Messenger.com) but in some cases they're distinct.

As I say it, there seem to be two(ish) main ways forward with this:

  1. Make it easier to badge the favicon
<link rel="shortcut icon badge" href="/favicon.ico" badge="99">
  1. Overload the badging API
Badge.set(99, { perInstance: true });

I'm partial to option one, as they do seem to be two distinct things (if you wanted to use both together, it should be possible to make a JS library). It would also be much easier to support things like glyph icons (difficult with the existing badge API because different OS's support different sets of glyphs/not at all, and this could mean your icon will be displayed differently in different places). With the link syntax we could have something like

<link rel="shortcut icon badge" href="/favicon.ico" badge="🌧">

And just specify that your character/number will be displayed in the bottom right corner of your page's tab icon.

(and sorry about the slow reply, I've been travelling the last two weeks)

This was referenced Jun 25, 2019
@fallaciousreasoning
Copy link
Collaborator

@mgiuca @marcoscaceres and I had a bit of a talk about this offline.

We're considering an API where urls are badged, as opposed to apps or tabs. When a url is badged, all urls in the url's scope are also badged. The most specific badge for a url is applied. If no scope is specified the origin should be badged.

Note we would either need to generalize the scope algorithm from the App Manifest or Service Worker specs or copy it into the spec for badging.

Basic Examples

// on https://site.com/index.html

// Sets the badge for https://site.com to be '5'. This will be applied to all urls on
// site.com which don't specify a badge.
Badge.set(5);

// Sets the badge for all tabs on https://site.com/index.html (and only that
// specific url) to be '7'.
Badge.set(7, { scope: '/index.html' });

For installed applications, the most specific badge which includes the web-app's scope is applied.

App Examples

// In an installed application with the scope https://my.app/stuff/actual-app/
Badge.set(7); // Set's the OS specific badge to 7
Badge.set(6, { scope: '/stuff' }); // Updates OS specific badge to 6
Badge.set(5, { scope: '/stuff/actual-app/' }); // Updates OS specific badge to 5
Badge.set(4, { scope: '/stuff/actual-app/page' }); // Doesn't effect OS badge, badges tab favicon for page.
Badge.set(99, { scope: '/stuff' }); // Doesn't effect OS badge (it's still 5).

Questions
Since we talked, I came up with some questions about clearing.

Badge.set(5);
Badge.set(10, { scope: '/index.html' });
Badge.clear({ scope: '/index.html' });

// What's the badge for index.html? Is it cleared? Or is it '5'?
// If its cleared, do we expect the same behavior for Badge.set(0, ...);
Badge.set(0, '/index.html);

I think clearing is going to be fairly complicated, as in some scenarios, apps will want to defer back to a parent scope, while in others, they explicitly want to be cleared.

@mgiuca @marcoscaceres any thoughts?

@kennethkufluk
Copy link

kennethkufluk commented Jul 15, 2019 via email

@fallaciousreasoning
Copy link
Collaborator

fallaciousreasoning commented Jul 16, 2019

Hmm, I could be convinced with regard to query strings (seems like it would be a pretty common scenario) but it would mean that Badging scope would work differently to scope in ServiceWorkers and AppManifests, which doesn't seem ideal.

Moving to a url with a structure like /search/This%20is%20my%20query/ could be a workaround but its a bit gross :/ @raymeskhoury @mgiuca @marcoscaceres, you guys know way more about specs than me, what do you think?

Colours definitely sound like something we could add support for in future but it almost certainly won't be in the initial version of the API. Would you mind creating a separate issue for it, so we don't lose track of it?

Something like this seems like it would make sense.

Badge.set(7, {
    scope: '/page',
    color: 'red' // Valid values from css colors? https://www.w3.org/TR/2018/REC-css-color-3-20180619/#colorunits
});

@marcoscaceres
Copy link
Member

Yeah, we probably want stick to the copying the scope behavior for SWs, otherwise things will get very confusing. If the SW one changes, the this one should change too.

About the colors, I'm not sure... I guess it could work for tabs, but there is a potential for accessibility problems (or then people wanting to change the text color too). I'd be more inclined to not add anything like this yet, as it's more of a "nice to have" feature. If we can get interop just to show a badge number for an app, that would already be a big achievement.

@mgiuca
Copy link
Collaborator

mgiuca commented Jul 18, 2019

color: 'red' // Valid values from css colors? https://www.w3.org/TR/2018/REC-css-color-3-20180619/#colorunits

I think we should refrain from adding colors right now. No platform I know of would be happy with injecting random colours to the badge since they all have their own style (e.g., Android uses the average color of the icon).

Other than that, this SGTM.

If we use the Manifest scope matching algorithm (which only checks the path), you wouldn't be able to set different badges on a page with the same path but different query. I think this is probably fine --- if you have different badge status for different pages then I think those should have different paths in your URL scheme. Though I could be convinced otherwise. I don't think "monitoring search result pages" is a strong enough use case to have a badge.

@marcoscaceres
Copy link
Member

I'm starting to swing back towards "tab only" and we should explore all possible avenues for cross tab communication. When the page navigates, we need to reload the favicon regardless, so as part of that, the document could update the Badge indicator on DOMContentLoaded or service worker registration.

If a page in another tab needs to update other tabs/windows, then could it use BroadcastChannel?

@fallaciousreasoning
Copy link
Collaborator

How would we distinguish between a badge to apply to the tab and a badge to apply to the app?

@mgiuca
Copy link
Collaborator

mgiuca commented Jul 18, 2019

Yeah whatever solution we come up with needs to allow for app icon badging (and not just the icon of an active window; also for the shelf icon of an app that currently doesn't have any windows open). That is Chrome's primary motivation for designing this API. We're happy to accommodate other use cases but we're not going to drop the app badging use case.

@mgiuca
Copy link
Collaborator

mgiuca commented Aug 16, 2019

There's a new explainer up which fully talks about app vs tab badging with equal weighting.

Closing this now, but I've opened a follow-up issue #49 to discuss whether we want these to be a single unified API or two separate APIs.

@mgiuca mgiuca closed this as completed Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants