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

Deliver as a PWA on the web #371

Open
1 of 7 tasks
bsidhom opened this issue Feb 22, 2024 · 6 comments
Open
1 of 7 tasks

Deliver as a PWA on the web #371

bsidhom opened this issue Feb 22, 2024 · 6 comments

Comments

@bsidhom
Copy link

bsidhom commented Feb 22, 2024

It would be great to make Numbat installable as a Progressive Web App (PWA). The key benefit of this is the ability to use it offline on any device with a modern web browser.

Here's the minimum set of changes needed to get core PWA functionality:

  • Web manifest. See also web.dev.
  • Icon assets. These will be associated with the installed PWA, either on desktop or home screen.
  • Service worker with full offline pre-caching of all mandatory static assets. At this point, this is likely the index page, WASM bundle, and any JS/CSS/fonts used. The ECB data is dynamic and should probably be fetched in a network-first fashion and only fetched on demand.

Some great follow-up features which could be done down the road but would really enhance the experience:

  • A first-class, web-forward UI as described in #218. Depending on how this materializes, it could be the default (or only) UI for all web users or we could have separate "desktop" and "mobile" options.
  • Persistent, offline user configs. As I'm currently envisioning it, this would basically just consist of user-defined modules saved across sessions (outside of URL params). For maximum compatibility, this would probably live in the origin-private file system. In truth, I would prefer full-fledged FS access (see the spec) so that users could literally share the same config files with their locally-installed CLI app, but it looks like Safari has no plans to support this (i.e., it looks like we'll be stuck with OPFS).
  • An install banner to make users aware they can install Numbat as an offline app.
  • Notification banner to prompt user to refresh/update when a new version is available. Otherwise, the old PWA version is retained until all live tabs with the site loaded are closed. Refreshing is not sufficient!

In any case, I think it would be a good exercise to start with the current web implementation and see how far we can go with the offline experience.

@bsidhom
Copy link
Author

bsidhom commented Feb 22, 2024

NOTE: At the moment, I'm only considering the core Numbat calculator app as being "in scope" for the PWA, but I assume we could easily cache the docs for offline use as well.

@bsidhom
Copy link
Author

bsidhom commented Feb 22, 2024

It looks like there are already icons. I'll need to check whether those already cover the obvious platforms, in which case we can check that off. 🙂

bsidhom added a commit to bsidhom/numbat that referenced this issue Feb 22, 2024
Addresses part of sharkdp#371.
@sharkdp
Copy link
Owner

sharkdp commented Feb 29, 2024

on any device with a modern web browser

If only this were true 🥲. Firefox does not have support for PWAs. And Apple is breaking PWA support for customers in Europe with iOS 17.4: https://techcrunch.com/2024/02/15/apple-confirms-its-breaking-iphone-web-apps-in-the-eu-on-purpose/?guccounter=1

@bsidhom
Copy link
Author

bsidhom commented Feb 29, 2024

Where did you hear about lack of Firefox support? It used to work. (Not sure about mobile to be clear; since what you typically care about with PWAs is offline functionality and separate window support, I expect that to be integrated into the default system browser, i.e., Safari on iOS and Chrome on Android.) As far as I can tell, Firefox removed windowed mode for PWAs (also known as single-site browser), but did not remove the PWA APIs that allow the app to operate (e.g., it should still work offline). And I think that's only on desktop in any case, where I'd be more likely to use a regular browser bookmark (even if offline).

For iOS, I'm less certain. One can only hope that this is a pre-release bug (not unheard of). If it's only happening in the EU, then hopefully Apple is eventually forced to allow third-party browser engines on iOS. I've been waiting for this since I first heard rumors. :) In any case, all three browsers on the major OSes should support service workers, etc. So the functionality is still there. The main problem I'm seeing now is that if the iOS 17.4 regression was intentional, then offline PWAs will only operate for up to 7 days, since they now use the shared browser GC policy rather than a separate app-specific one.

@bsidhom
Copy link
Author

bsidhom commented Feb 29, 2024

More specifically, we can project compatibility onto the dimensions we care about:

And that's basically it.

If we wanted to get fancier and maintain some sort of shared memory app state, we could even use newer technologies such as broadcast channels and/or web locks. Honestly, I'd be surprised if any of these already-shipped features were removed or deprecated suddenly. I think my biggest concern now is around iOS (just in the EU?) deleting your offline stuff more aggressively in the future. But that's no worse than the pre-PWA situation. :)

@sharkdp
Copy link
Owner

sharkdp commented Mar 5, 2024

Where did you hear about lack of Firefox support?

image

https://en.wikipedia.org/wiki/Progressive_web_app#Browser_support

Your version in #372 actually works fine in Firefox on Android though!

Firefox removed windowed mode for PWAs (also known as single-site browser), but did not remove the PWA APIs that allow the app to operate (e.g., it should still work offline).

Right. The service worker APIs still work fine.

For iOS, I'm less certain. One can only hope that this is a pre-release bug (not unheard of). If it's only happening in the EU, then hopefully Apple is eventually forced to allow third-party browser engines on iOS. I've been waiting for this since I first heard rumors. :)

I don't think it was a bug. It was intentional. But in the meantime, they backtracked, apparently: https://appleinsider.com/articles/24/03/01/apple-reverses-course-on-death-of-progressive-web-apps-in-eu

So yeah, let's try this 👍. Sorry for being so reluctant.

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

2 participants