-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Switch to ServiceWorker mode by default #196
Comments
It would be great if you could add some more detail on the difference between these two modes? I think it will help future contributors to get a better idea of the code and why they exist. Right now given the two different formats zim/evo archive, two different content injection modes (probably a third coming with webrequest), the weird zim format(whose advantages aren't clear), references to firefox os/geo location etc the barrier to entry for a dev to figure out what is going on is a bit high. I think this is a fantastic project with lot of potential for all kinds of offline use-cases and I feel you will get more devs involved and exploring those use cases, if the core pieces of this project are well documented. Thanks for all the work you guys do! |
I agree that the Service Worker approach is cleaner, and the logical way to do things. Effectively, we've written an emulation of ServiceWorker in jQuery, which is quite high maintenance. However, I perceive a number of issues with Service Worker still:
|
Firefox has implemented Service Workers, and it works for me when running from localhost (without https). They are however disabled in ESR versions (so far) : Firefox 52 ESR and Firefox 60 ESR. Please check you're not using an ESR version. https should be required for Service Workers only when the host is distant (not from localhost) But, for now, Firefox disables Service Workers inside a browser extension. I've asked to enable them in https://bugzilla.mozilla.org/show_bug.cgi?id=1344561 : they first answered no, but finally answered yes (but they currently have no timeline for doing it) Service Workers are disabled under the file:// protocol. It's true that it's at least annoying for development. But I'm not sure double-clicking on index.html is the major use case. IMHO, major use-cases are currently running as an app on mobile and other non-desktop platforms (Windows, FFOS, Ubuntu Touch, maybe other ones), and running as a browser extension. I'm not sure for UWP and Ubuntu touch apps, but the other contexts do not use file:// protocol. In any case, it's something we might ask to the browsers vendors, because I don't see the security threat (provided that the Service Worker only traps requests from its own content to its own content) It's true that Service Workers are not usable in all contexts. That's why we need to keep the jQuery mode as a fallback. |
Apologies, yes, Service Worker is now working for me on Firefox Quantum in localhost. what happens is that sometimes I've been using the ESR version of Firefox, and then when I open the Quantum profile it nevertheless loads up ESR, probably because ESR hasn't fully exited, and that confused me. Your strategy seems good to me. I think so long as a version is still available that works without SW in the medium term, it'll be fine to initiate a pivot towards SW. UWP works in app context, not in file: context, so Service Workers will work if targeting the latest SDK (but I can't do that because of mobile). |
I would be happy to see this implemented, assuming the device would silently fall back to jQuery mode if SW is not implemented on first startup. Thereafter, if a user attempts to switch to SW mode on a non-supported device, they would receive an explicit error message explaining why not. Regarding #404, I can fix it for you with one line of code, but you won't like the solution (!). I don't think #404 is a blocker, but it is poor UX. However, it should be discussed further there. Are you happy to implement this issue? (I'm travelling and away from my dev machine for the next week.) |
I agree. The idea is to use SW mode (by default) on platforms that support it, and automatically fallback to jQuery mode (by default) where it's not. Yes, I can implement it (it is already assigned to me). But I probably won't be able to do that in the near future. I have many things to do (aside from kiwix-js) that will let me very little availability to actually develop, until the end of January 2020. |
#732 is in milestone 3.6 which makes it impossible to implement this ticket in 3.5 milestone. |
I've started to work a bit on that. I've created a new branch "Switch-to-SW-mode-by-default", but it's still a work-in-progress |
@mossroy Can I (or you if you wish) rebase that branch "Switch-to-SW-mode-by-default" on master and then open a PR? I think it would be good to list the steps that need to be completed. In principle, I don't think it's complicated, as the PWA version (moz-extension.kiwix.org) already starts in SW mode by default, but maybe there are some complications we need to take into account, or fallbacks/tests we need to put in place. |
PS I only ask because you started that work. |
Sure, you can. It should not be very complicated, but is not really straight-forward either.
The case of old Firefox browsers with no SW support should be tested, just to check the UX is not too awful, without spending too much time on them (remember what we wrote in 53ba099#diff-484c9e8aa09e09b8eb1fafaf55e8eadcd0eaab230e38d02bb9440841bfa090a4R786) |
Forgot to mention that all these use-cases are only relevant if we want to keep the very broad compatibility we kept since today |
The ServiceWorker mode is faster and cleaner.
At startup, we should first try to enable it by default (except if the user has chosen jQuery mode before).
If it fails, we fallback to jQuery mode.
The text was updated successfully, but these errors were encountered: