| Summary: | ServiceWorker downloads do not start in reopened tabs | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | mrskman |
| Component: | Page Loading | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Normal | CC: | beidson, cdumez, kkinnunen, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac (Intel) | ||
| OS: | macOS 12 | ||
|
Description
mrskman
2022-04-06 06:37:47 PDT
Quickly looking at it, I can see that WebPage::didReceivePolicyDecision policyAction is set to 2 (ignore) in the download failure case while it is set to 1 (download) in the working case. (In reply to youenn fablet from comment #2) > Quickly looking at it, I can see that WebPage::didReceivePolicyDecision > policyAction is set to 2 (ignore) in the download failure case while it is > set to 1 (download) in the working case. Is there any workaround for this? Is the "Service Workers" component category correct or should I change it? Thank you! The workaround is to trigger the download synchronously as part of the click event handler. Then everything will work fine from there. This is not specific to service worker, I would expect that a setTimeout would also trigger that same behavior. This is controlled by Safari code and I am not sure why this behavior is like this. I will send the bug report there. Downloads there are always asynchronous (navigator.serviceWorker.register is called first), so setTimeout is working fine until you reopen the tab. You can test it with the third button I've added. (In reply to mrskman from comment #5) > Downloads there are always asynchronous (navigator.serviceWorker.register is > called first), so setTimeout is working fine until you reopen the tab. Right, so one workaround so far is to register a service worker specifically for downloads, in advance, then the download can be triggered synchronously in the click event handler. > You can test it with the third button I've added. Thanks for the updated test. (In reply to youenn fablet from comment #6) > Right, so one workaround so far is to register a service worker specifically > for downloads, in advance, then the download can be triggered synchronously > in the click event handler. Which is pain if you need to negotiate the download with server first based on what user chooses. And then there is a chance, that browser has already unregistered the service worker. Anyway thank you! |