Downloading via ServiceWorker API stopped working in v70
Reported by
mrsk...@gmail.com,
Oct 18
|
|||||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36 Steps to reproduce the problem: 1. Register attached ServiceWorker 2. Navigate to to the registered SW URL What is the expected behavior? File called 'file.bin' (5 bytes) should be downloaded What went wrong? Nothing happens Did this work before? Yes 69 Does this work in other browsers? N/A Chrome version: 70.0.3538.67 Channel: stable OS Version: Flash Version:
,
Oct 18
Here is a testing URL: https://stat-info.cz/chrome-sw-download.html
,
Oct 18
Yes, it works after disabling that feature
,
Oct 18
Thanks. I can reproduce as well. When it fails it gives the console error message: Resource interpreted as Document but transferred with MIME type application/octet-stream: "https://stat-info.cz/download" Note, this fails with network service enabled as well.
,
Oct 18
That console message was there always as I remember (something with headers I guess) but the download was working.
,
Oct 18
This issue is preventing Office 365 users from downloading attachments when using Chrome with the web version of Outlook. I'm a developer in Office 365, and I'm investigating a workaround on our side. A fix to the root cause would be even better though. :-) Thanks!
,
Oct 19
I tested the stat-info.cz site on Chrome 70. ServiceWorkerServicification off, NetworkService off: download occurs (with console warning) ServiceWorkerServicification on, NetworkService off: no download ServiceWorkerServicification on, NetworkService on: no download There appears to be a similar issue at https://bugs.chromium.org/p/chromium/issues/detail?id=896161#c12 since it's something involving content-disposition. However, it's reported there that it works when both ServiceWorkerServicification and NetworkService are on. It only fails when only ServiceWorkerServicification is on.
,
Oct 19
For more context, this broke due to the ServiceWorkerServicification variation launching to 100% for Chrome 69+ Stable. It was previously at 1%. It's been rolled back to 1% so for most users this should soon work again. A workaround is to disable "Servicified service workers" as described in comment 1.
,
Oct 19
,
Oct 19
Just guessing but maybe we need something similar to MimeSniffingResourceHandler::MustDownload() in ServiceWorkerServicification path? https://cs.chromium.org/chromium/src/content/browser/loader/mime_sniffing_resource_handler.cc?l=563&rcl=3d87f18eebc763c1f14e0735af3325595075d67f
,
Oct 19
Good find. For reference, the demo site is doing this:
navigator.serviceWorker.register('/sw.js', { scope: '/download' }).then(function() {
window.location.href = '/download';
});
Where sw.js does:
headers.append('Content-Type', 'application/octet-stream; charset=UTF-8');
headers.append('Content-Disposition', "attachment; filename=\""+ filename +"\"; filename*=UTF-8''"+ filename); // RFC 5987
headers.append('Content-Length', '5');
/** @type {!Response} */
var response = new Response('abcde', { headers:headers });
evt.respondWith(response);
,
Oct 19
I found a code to prevent the response from downloading when URLLoaderThrottle intercepts a request: https://cs.chromium.org/chromium/src/content/browser/loader/navigation_url_loader_impl.cc?sq=package:chromium&g=0&l=1132 Currently there are two implementation of MimeSniffing : network::URLLoader and MimeSniffingThrottle when either of S13nSW and NetworkService is on. When the request goes to the network and sniffed by network::URLLoader, MimeSniffingThrottle won't be used and the response will be downloaded. However, if the request goes to a service worker, MimeSniffingThrottle handles the response and it flips |response_intercepted| to true and it results in preventing the response from downloading. I guess the code was introduced for checking if the response may be served by ChromeContentBrowserClient::CreateURLLoaderThrottles(), but probably we need another way to check if we really can prevent downloading. https://cs.chromium.org/chromium/src/chrome/browser/chrome_content_browser_client.cc?sq=package:chromium&dr=CSs&g=0&l=4328 Or, maybe we can just remove the check? I'm still not sure why it's needed. kinuko: can you give me a hint about that?
,
Oct 19
Let me correct "the response may be served by ChromeContentBrowserClient::CreateURLLoaderThrottles()" to "the response may be served by a throttle created by ChromeContentBrowserClient::CreateURLLoaderThrottles()"
,
Oct 19
The comment here looks relevant (and incorrect):
// Currently only plugin handlers may intercept the response. Don't treat
// the response as download if it has been handled by plugins.
bool response_intercepted = false;
Seems we need a better mechanism that tells you whether it was intercepted by a plugin or not.
,
Oct 19
,
Oct 19
[falken]: How long does it take for that feature to be automatically disabled again without any users' interaction? Because most of our users won't be able to do this by hand.
,
Oct 19
This issue is currently resolved as per the comment about reverting the ServiceWorkerServicification variation launching to 1%. I still don't completely understand why this did not break on any Linux we tested on, both version 69 and 70. If someone can explain that to me please. And also just a note on the comment left by falcon@chromium.org (comment 7). There appears to be a similar issue at https://bugs.chromium.org/p/chromium/issues/detail?id=896161#c12 since it's something involving content-disposition. However, it's reported there that it works when both ServiceWorkerServicification and NetworkService are on. It only fails when only ServiceWorkerServicification is on. That I did not mention that it works when both ServiceWorkerServicification and NetworkService are on, it definitely broke when both were on.
,
Oct 19
c#16: It should be disabled automatically without user interaction. It might require a browser restart. It is true that for a small percentage of the users, the bug will still occur, but having the feature enabled at 1% may allow to us to discover other issues before we try to launch it again. We're working on pushing out a real fix for this bug in the meantime. c#17: Thanks for clarifying that it also broke with NetworkService. That's aligned with our observations too then. Regarding Linux, I don't know the cause. The issue is triggered by MIME sniffing which could possibly have different behavior depending on the platform. I think the issue may also be fixed server-side by giving the response a content-type other than octet-stream and thus bypassing MIME sniffing, but I'm not sure.
,
Oct 19
I'm probably understanding the bug. NavigationURLLoader has a mechanism to skip download when plugin handled the response. As I mentioned in c#12, MimeSniffingThrottle triggers it and download didn't happen. Also, NavigationRequest::OnWillProcessResponseChecksComplete() has a branch of how to handle the response [1]. When NetworkService is on, we need to route the response to the DownloadManager here. When S13nSW is on and the response was from a service worker, it also needs to be routed there. [1] https://cs.chromium.org/chromium/src/content/browser/frame_host/navigation_request.cc?gsn=WillProcessResponse&g=0&l=1476 I have a quick fix on the former, but I'm still thinking a good way to fix the latter. But anyway, I could confirm https://stat-info.cz/chrome-sw-download.html works well after solving these two issues in my local build. combrink.jc: in your case, I think mime sniffing wasn't triggered because the content-type was application/pdf. In that case, it works even when NetworkService is on. https://stat-info.cz/chrome-sw-download.html has a different content-type, and that triggers MimeSniffing. In that case, both of S13nSW/NetworkService don't work.
,
Oct 19
Thanks for clarifying shimazu@chromium.org. I do have a better understanding of the issue now.
,
Oct 23
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/0885b0f00f3e198e81a9a00ad8363ea48aa4d355 commit 0885b0f00f3e198e81a9a00ad8363ea48aa4d355 Author: Makoto Shimazu <shimazu@chromium.org> Date: Tue Oct 23 10:29:02 2018 Skip downloading by using a flag in ResourceResponse When NetworkService/ServiceWorkerServicification is on, MimeSniffingThrottle is used for responses from service workers. Previously, downloading is skipped when any of throttles handle the response, so using MimeSniffingThrottle undesirably prevented downloading. This CL is to make downloading work properly when a service worker serves the response. Also, when a response is NOT served from ResourceDispatcherHost, DownloadManagerImpl needs to be created in NavigationRequest. Currently it happens only when NetworkService is on. This CL adds a condition where S13nSW is on and a service worker serves the response there. TBR=jam@chromium.org Bug: 896696 Cq-Include-Trybots: luci.chromium.try:linux_mojo Change-Id: I222d8148cf65d15492393ebcd6ed582deb14022f Reviewed-on: https://chromium-review.googlesource.com/c/1290434 Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Commit-Position: refs/heads/master@{#601901} [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.cc [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/browser/download/download_browsertest.cc [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/browser/frame_host/navigation_request.cc [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/browser/loader/navigation_url_loader_impl.cc [add] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/test/data/fetch_event_octet_stream.js [add] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/test/data/fetch_event_passthrough.js [add] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/test/data/fetch_event_respond_with_fetch.js [add] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/content/test/data/register_service_worker.html [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/services/network/public/cpp/resource_response.cc [modify] https://crrev.com/0885b0f00f3e198e81a9a00ad8363ea48aa4d355/services/network/public/cpp/resource_response_info.h
,
Oct 23
,
Oct 23
This bug requires manual review: Request affecting a post-stable build Please contact the milestone owner if you have questions. Owners: benmason@(Android), kariahda@(iOS), geohsu@(ChromeOS), abdulsyed@(Desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 23
This just landed 5 hours ago. We can't take this to stable until it has baked in earlier channels.
,
Oct 23
this is the change is hidden behind a flag so should only impact S13SW users (on at 1%).
,
Oct 23
,
Oct 23
This bug requires manual review: Request affecting a post-stable build Please contact the milestone owner if you have questions. Owners: benmason@(Android), kariahda@(iOS), geohsu@(ChromeOS), abdulsyed@(Desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 23
RC is already cut, there is not justification for why this is critical, and this has not landed in any earlier channels, and we can't take this directly to stable.
,
Oct 24
this is verified with chrome 72.0.3590.0. Requesting merge again. The reason we are asking for the merge is that this is blocking the Network Service (approved for M70 stable exp). This has no impact outside of Network Service users which will have very little risk to stable population. Hope you will consider this for the next Stable 70 RC
,
Oct 24
This bug requires manual review: Request affecting a post-stable build Please contact the milestone owner if you have questions. Owners: benmason@(Android), kariahda@(iOS), geohsu@(ChromeOS), abdulsyed@(Desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 25
Approving merge for M70, now that this has baked in canary. There is no respin planned at the moment; however let's merge this so it's included if there is a respin.
,
Oct 25
I guess you probably want to merge this to 71 as well?
,
Oct 25
,
Oct 25
This bug requires manual review: M71 has already been promoted to the beta branch, so this requires manual review Please contact the milestone owner if you have questions. Owners: benmason@(Android), kariahda@(iOS), kbleicher@(ChromeOS), govind@(Desktop) For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 25
Approving merge for M71 branch 3578 based on comment #29. Please merge ASAP so we can pick it up for next week beta. Thank you.
,
Oct 25
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e3e6842e9e5390a627a006d5e56037108acaa84c commit e3e6842e9e5390a627a006d5e56037108acaa84c Author: Makoto Shimazu <shimazu@chromium.org> Date: Thu Oct 25 17:59:42 2018 Skip downloading by using a flag in ResourceResponse When NetworkService/ServiceWorkerServicification is on, MimeSniffingThrottle is used for responses from service workers. Previously, downloading is skipped when any of throttles handle the response, so using MimeSniffingThrottle undesirably prevented downloading. This CL is to make downloading work properly when a service worker serves the response. Also, when a response is NOT served from ResourceDispatcherHost, DownloadManagerImpl needs to be created in NavigationRequest. Currently it happens only when NetworkService is on. This CL adds a condition where S13nSW is on and a service worker serves the response there. TBR=jam@chromium.org Bug: 896696 Cq-Include-Trybots: luci.chromium.try:linux_mojo Change-Id: I222d8148cf65d15492393ebcd6ed582deb14022f Reviewed-on: https://chromium-review.googlesource.com/c/1290434 Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#601901}(cherry picked from commit 0885b0f00f3e198e81a9a00ad8363ea48aa4d355) Reviewed-on: https://chromium-review.googlesource.com/c/1299773 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Cr-Commit-Position: refs/branch-heads/3578@{#326} Cr-Branched-From: 4226ddf99103e493d7afb23a4c7902ee496108b6-refs/heads/master@{#599034} [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.cc [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/browser/download/download_browsertest.cc [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/browser/frame_host/navigation_request.cc [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/browser/loader/navigation_url_loader_impl.cc [add] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/test/data/fetch_event_octet_stream.js [add] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/test/data/fetch_event_passthrough.js [add] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/test/data/fetch_event_respond_with_fetch.js [add] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/content/test/data/register_service_worker.html [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/services/network/public/cpp/resource_response.cc [modify] https://crrev.com/e3e6842e9e5390a627a006d5e56037108acaa84c/services/network/public/cpp/resource_response_info.h
,
Oct 25
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/e3e6842e9e5390a627a006d5e56037108acaa84c Commit: e3e6842e9e5390a627a006d5e56037108acaa84c Author: shimazu@chromium.org Commiter: jam@chromium.org Date: 2018-10-25 17:59:42 +0000 UTC Skip downloading by using a flag in ResourceResponse When NetworkService/ServiceWorkerServicification is on, MimeSniffingThrottle is used for responses from service workers. Previously, downloading is skipped when any of throttles handle the response, so using MimeSniffingThrottle undesirably prevented downloading. This CL is to make downloading work properly when a service worker serves the response. Also, when a response is NOT served from ResourceDispatcherHost, DownloadManagerImpl needs to be created in NavigationRequest. Currently it happens only when NetworkService is on. This CL adds a condition where S13nSW is on and a service worker serves the response there. TBR=jam@chromium.org Bug: 896696 Cq-Include-Trybots: luci.chromium.try:linux_mojo Change-Id: I222d8148cf65d15492393ebcd6ed582deb14022f Reviewed-on: https://chromium-review.googlesource.com/c/1290434 Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#601901}(cherry picked from commit 0885b0f00f3e198e81a9a00ad8363ea48aa4d355) Reviewed-on: https://chromium-review.googlesource.com/c/1299773 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Cr-Commit-Position: refs/branch-heads/3578@{#326} Cr-Branched-From: 4226ddf99103e493d7afb23a4c7902ee496108b6-refs/heads/master@{#599034}
,
Oct 25
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c76cfee500651030c4cc271bdf6dff8b92570271 commit c76cfee500651030c4cc271bdf6dff8b92570271 Author: John Abd-El-Malek <jam@chromium.org> Date: Thu Oct 25 18:09:26 2018 Skip downloading by using a flag in ResourceResponse When NetworkService/ServiceWorkerServicification is on, MimeSniffingThrottle is used for responses from service workers. Previously, downloading is skipped when any of throttles handle the response, so using MimeSniffingThrottle undesirably prevented downloading. This CL is to make downloading work properly when a service worker serves the response. Also, when a response is NOT served from ResourceDispatcherHost, DownloadManagerImpl needs to be created in NavigationRequest. Currently it happens only when NetworkService is on. This CL adds a condition where S13nSW is on and a service worker serves the response there. TBR=jam@chromium.org, shimazu@chromium.org (cherry picked from commit 0885b0f00f3e198e81a9a00ad8363ea48aa4d355) Bug: 896696 Cq-Include-Trybots: luci.chromium.try:linux_mojo Change-Id: I222d8148cf65d15492393ebcd6ed582deb14022f Reviewed-on: https://chromium-review.googlesource.com/c/1290434 Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#601901} Reviewed-on: https://chromium-review.googlesource.com/c/1299740 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Cr-Commit-Position: refs/branch-heads/3538@{#1047} Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811} [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/chrome/browser/plugins/plugin_response_interceptor_url_loader_throttle.cc [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/browser/download/download_browsertest.cc [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/browser/frame_host/navigation_request.cc [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/browser/loader/navigation_url_loader_impl.cc [add] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/test/data/fetch_event_octet_stream.js [add] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/test/data/fetch_event_passthrough.js [add] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/test/data/fetch_event_respond_with_fetch.js [add] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/content/test/data/register_service_worker.html [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/services/network/public/cpp/resource_response.cc [modify] https://crrev.com/c76cfee500651030c4cc271bdf6dff8b92570271/services/network/public/cpp/resource_response_info.h
,
Oct 25
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/c76cfee500651030c4cc271bdf6dff8b92570271 Commit: c76cfee500651030c4cc271bdf6dff8b92570271 Author: jam@chromium.org Commiter: jam@chromium.org Date: 2018-10-25 18:09:26 +0000 UTC Skip downloading by using a flag in ResourceResponse When NetworkService/ServiceWorkerServicification is on, MimeSniffingThrottle is used for responses from service workers. Previously, downloading is skipped when any of throttles handle the response, so using MimeSniffingThrottle undesirably prevented downloading. This CL is to make downloading work properly when a service worker serves the response. Also, when a response is NOT served from ResourceDispatcherHost, DownloadManagerImpl needs to be created in NavigationRequest. Currently it happens only when NetworkService is on. This CL adds a condition where S13nSW is on and a service worker serves the response there. TBR=jam@chromium.org, shimazu@chromium.org (cherry picked from commit 0885b0f00f3e198e81a9a00ad8363ea48aa4d355) Bug: 896696 Cq-Include-Trybots: luci.chromium.try:linux_mojo Change-Id: I222d8148cf65d15492393ebcd6ed582deb14022f Reviewed-on: https://chromium-review.googlesource.com/c/1290434 Commit-Queue: Makoto Shimazu <shimazu@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#601901} Reviewed-on: https://chromium-review.googlesource.com/c/1299740 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Cr-Commit-Position: refs/branch-heads/3538@{#1047} Cr-Branched-From: 79f7c91a2b2a2932cd447fa6f865cb6662fa8fa6-refs/heads/master@{#587811}
,
Oct 25
,
Oct 30
,
Nov 9
Able to reproduce this issue on Windows 10, mac OS 10.13.6 and Ubuntu 17.10 on the reported version 70.0.3538.67 and the issue is fixed on the latest M-70 build 70.0.3538.102. 1. Launched Chrome and enabled the flags #enable-service-worker-servicification and #network-service in chrome://flags. 2. Navigated to the URL provided in comment #2 and on hitting the download button, 'file.bin' file is downloaded. Attached is the screen cast for reference. Hence adding TE verified labels as the fix is working as intended. Thanks..
,
Nov 16
Android: Works as per expected behavior, Able to download the file. Verified on 70.0.3538.110 |
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by wanderview@chromium.org
, Oct 18