-
Notifications
You must be signed in to change notification settings - Fork 42
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
backgroundfetchclick event handler is optional #147
Comments
Another thing to consider is that the click event might be delayed until the service worker is activated. Similarly, if there are a lot of bgfetch that terminate, they are enqueued in the same queue. They might be fired before a click event, thus potentially delaying the click event handler execution noticeably. One way of solving this is for click events to be processed in a different queue. |
We could add an option to background fetch which provides a default URL, then, if that's provided Are you seeing particularly long service worker startup times?
This feels like a loss of functionality. For instance, if I'm uploading a group of photos, or a video, I might not know the destination URL of the upload before the upload begins.
Is this likely? Feels like you'd be pretty unlucky to hit that. |
Agreed this is very similar and we need a good click-to-service-worker model for both.
It is very dependent on the situation.
That may not be likely but we want to ensure a reliable experience whatever the state of the processes or service workers are. Especially since we are talking of the user clicking on User Agent UI. Ideally, it should be possible to not execute any website JS to properly react to the user click. When clicking on a User Agent UI fetch entry, the user expectation is probably to have an existing page getting focus or a new page being shown. bgfetch could enforce this pattern as follows:
There are some benefits to this approach:
There might be different ways to allow a website tuning the client selection, for instance:
|
There's a tension here between this and #145. The proposal there is to delay firing things like the success event until the service worker runs in reaction to user interaction. This will likely make the click reaction slower. |
A service worker that manages background fetches is not required to handle backgroundfetchclick events. Similarly, a bug in a backgroundfetchclick event handler (an early return, a rejected promise, a spin or a very long processing time) might trigger the same issue of user clicking on the User Agent UI showing bg fetches and nothing happens.
This would like as if the User Agent has a bug.
This seems undesirable and I wonder whether User Agents could implement a fallback.
If we look at the the fetch event, User Agents can always fallback to the network for instance.
One possibility would be to associate an URL to a bgfetch that could be used by the User Agent when appropriate. This URL could be the service worker registration scope URL. Or the scope URL could only be a default and the web application could provide its own URL (maybe with the problem/constraint that the URL should match the service worker registration).
If we go further down the road of this idea, we could think of removing backgroundfetchclick and only rely on this URL. We could probably provide hooks to allow User Agents to optimise its UI in case of a service worker wanting to reuse an existing page instead of loading the URL on a new page.
The text was updated successfully, but these errors were encountered: