kiwix / kiwix-js-pwa

Kiwix JS Offline Browser implemented as a Progressive Web App (PWA), and packaged as Electron, NWJS and UWP apps for Windows and Linux.
https://pwa.kiwix.org
GNU General Public License v3.0
177 stars 29 forks source link

Use `skipWaiting()` in the Electron app to ensure immediate update after upgrade install #558

Open Jaifroid opened 7 months ago

Jaifroid commented 7 months ago

The Electron app's upgrade process may be a bit confusing for users. With the exe and AppImage versions, it will download updated code in the background while the user is using the app (if they allowed auto-update), and then offer the update, asking users to restart. However, due to the change in architecture whereby the app runs as a (fully local) PWA under the hood, it isn't fully updated after the restart. It will need a FURTHER restart for the PWA to update itself from the new code.

There is a way to upgrade a PWA immediately, using skipWaiting(). However, that is not a good experience for standard PWA users because it makes upgrades more intrusive (they can interrupt the browsing session). So we need to be able to detect the situation, which is a bit tricky, but probably achievable.

Jaifroid commented 4 months ago

I've investigated this a bit, but calling skipWaiting() on its own once the Cache Promises have completed doesn't do the job. It's possible that combining this with an auto-refresh (reload) might work, but it would be important to ensure that it is not obvious or disruptive to the user.