Problem/Motivation

Currently, the manifest functionality can NOT be used without the service worker being activated. The service worker itself only provides the offline functionality of the app and isn't a core feature of a PWA. It also isn't one of the 'install criterias' for a PWA (anymore): https://web.dev/install-criteria/#criteria (Atleast for chrome).
And at last, there are currently quite a few problems with the service worker implementation inside this module (see #3377120: [META][pwa_service_worker] Refactor 'pwa_service_worker' implementations and flaws).

Steps to reproduce

Proposed resolution

Decouple service worker from manifest through a dedicated "service worker submodule"

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork pwa-3388800

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Grevil created an issue. See original summary.

grevil’s picture

Status: Active » Needs review

Alright, this should be all done now. After running "drush updb" I still get an apparent manifest.json schema error, but after clearing all cashes it's not there anymore.

Should we find the right caches to clear on update hook? Or let the user run it himself?
Furthermore, we still need to clear the old service worker inside our update hook.

But this can be reviewed already. 🙂

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Grevil, this wasn't a simple task, but looks really really good!

Due to the many changes I wasn't able to compare every single line, but I trust you made the changes very carefully and took the time to test everything. Once you're sure it' fine, let's merge this one in and make some final tests with the dev version.

Afterwards, let's release 2.1.0-alpha1

anybody’s picture

grevil’s picture

Status: Reviewed & tested by the community » Needs work

Ok, I understood the service worker cache version now, pretty smart!

// When Drupal replaces `cacheVersion` during server-side processing, it includes
// the packaged version number. That means any module upgrade will automatically
// result in a fresh SW installation.

So basically the cache version of the service worker is generated by the integer set in the configuration + the "version" from the info.yml. Meaning the old service worker will discard itself on update!! :)

We should also manually reset the cache version config to 1 on every update! So the admins can up them manually and don't have to start from their old cache version!

Now we only need to clear the correct caches for the manifest.

grevil’s picture

Assigned: grevil » Unassigned
Status: Needs work » Needs review

Alright, all done. As internally discussed with @Anybody, we'll simply flush all caches on update, since it would take too long, to pin point the correct caches to clear here. Final review pls! :)

anybody’s picture

Status: Needs review » Reviewed & tested by the community

  • Anybody committed 5aecc230 on 2.x authored by Grevil
    Issue #3388800 by Grevil, Anybody: Decouple service worker from manifest...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

MERGED! Great!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.