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

Firefox extension does not switch to the PWA any more since Firefox 103.0 #877

Closed
mossroy opened this issue Aug 4, 2022 · 6 comments · Fixed by #878
Closed

Firefox extension does not switch to the PWA any more since Firefox 103.0 #877

mossroy opened this issue Aug 4, 2022 · 6 comments · Fixed by #878
Labels
regression Broken things that used to work
Milestone

Comments

@mossroy
Copy link
Contributor

mossroy commented Aug 4, 2022

On several devices where I have kiwix-js 3.4.0 Firefox extension installed, it no longer switches to the PWA when trying to use the ServiceWorker mode.
It says "The ServiceWorker API is not available on your device. Falling back to JQuery mode".

I suspect that there has been a change in Firefox behavior, in version 103.0.
In previous version of Firefox, the ServiceWorker API was available in extensions ('serviceWorker' in navigator returned true), but failed to register. And we trapped this registraion exception to propose a switch to the PWA (when inside a Firefox extension).

In my current version (103.0 64 bits on Ubuntu), 'serviceWorker' in navigator now returns false in the extension, so kiwix-js does not propose to use the PWA, and fallbacks to jQuery mode.

I do not see any mention of this change in https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/103 so am not 100% sure

@mossroy mossroy added the regression Broken things that used to work label Aug 4, 2022
@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

I downloaded a few Firefox versions from https://ftp.mozilla.org/pub/firefox/releases/ (linux 64-bits versions), ran them in a VM, and tested to switch to SW mode in Kiwix extension on each:

  • 100.0.2: works (proposes the PWA)
  • 101.0.1: works (proposes the PWA)
  • 102.0.1: works (proposes the PWA)
  • 103.0: fails
  • 103.0.1: fails

(if you try to reproduce, don't get fooled by the fact that these versions have auto-update enabled: on restart, you can end up on latest version instead of the one you extracted)

@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

I probably found the relevant change in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1593931

@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

The first solution I would think of would be to switch to the PWA if the protocol is moz-extension and the ServiceWorker API is unavailable.

It would work for recent versions of Firefox, but could be a problem for some old versions that really do not support ServiceWorkers (or have it disabled). In this case, the extension would suggest a switch to the PWA, that would not work either.

Based on https://caniuse.com/serviceworkers , the affected versions would be:

  • Firefox 42 and 43 (Firefox 42 is the first version we officially support in the extension manifest)
  • Firefox 45 ESR
  • Firefox 52 ESR
  • Firefox 60 ESR
  • Firefox 68 ESR
    (Firefox OS should not be affected as it uses a protocol different than 'moz-extension', IIRC)

We should test if the behavior is acceptable on these browser versions. At the very least, the user should be able to switch back to local jQuery mode.

mossroy added a commit that referenced this issue Aug 4, 2022
This is necessary for Firefox >=103, where the ServiceWorker API has been
removed in WebExtensions.
See https://hg.mozilla.org/integration/autoland/rev/3a2907ad88e8

Fixes #877
mossroy added a commit that referenced this issue Aug 4, 2022
This is necessary for Firefox >=103, where the ServiceWorker API has been
removed in WebExtensions.
See https://hg.mozilla.org/integration/autoland/rev/3a2907ad88e8

Fixes #877
mossroy added a commit that referenced this issue Aug 4, 2022
This is necessary for Firefox >=103, where the ServiceWorker API has been
removed in WebExtensions.
See https://hg.mozilla.org/integration/autoland/rev/3a2907ad88e8

Fixes #877
@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

Maybe we should quickly release a new kiwix-js version with this fix?

@Jaifroid
Copy link
Member

Jaifroid commented Aug 4, 2022

Maybe we should quickly release a new kiwix-js version with this fix?

Yes, I agree. We don't want people using the extension suddenly finding that they can't switch to SW mode, especially given the aggressive updating that all modern browsers do without giving users much control over it.

@mossroy
Copy link
Contributor Author

mossroy commented Aug 4, 2022

OK I'll create the ticket with the TODO-list

@mossroy mossroy added this to the v3.5 milestone Aug 4, 2022
mossroy added a commit to mossroy/content that referenced this issue Aug 5, 2022
The ServiceWorker API has been removed inside a Webextension.
With Firefox<103, the API was available, but registering a ServiceWorker was failing on a security issue.
Since Firefox 103, the API is not available at all.

It's a significant change, that broke our kiwix extension (see kiwix/kiwix-js#877).
So I think it's worth mentioning it here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Broken things that used to work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants