Issue metadata
Sign in to add a comment
|
Not getting callback inWebview's onPageFinished() method for file download in chrome version 69
Reported by
chauhan....@gmail.com,
Sep 26
|
||||||||||||||||||||||
Issue descriptionSteps to reproduce the problem: Please use webview based app with chrome version 69 installed on the device. Follow these steps to replicate the issue: 1. Search "sample pdf download" on google 2. Click on any pdf file, the download will start 3. Observe that we get a callback in onPageStarted() method but not in onPageFinished(). What is the expected behavior? What went wrong? We should get callback in onPageFinished() as was happening with previous versions of chrome. Did this work before? Yes Chrome version: 69.0.3497.100 Channel: stable OS Version: 8.0 Flash Version:
,
Sep 27
@chauhan.deepti24: Could you please let us know where to check onPageFinished() callbacks. Please provide sample app and screencast on reproducing the issue. Thanks!
,
Sep 27
Please find attached a sample apk to replicate the issue. It will open up a webview with google as homepage. Observe the issue by following these steps: 1) Attach device to system so that you can see the logs.Search for logs with tag "WebViewDemo" 2) Type "sample pdf download" in search box. You will notice that we get onPageStarted() and onPageFinished() for all the urls'. Now click on a pdf download link, you will observe we get a callback in onPageStarted() but not in onPageFinished(). We get a callback in onDownloadStart() directly. Ideally we should get callback in onPageFinished() as well before getting callback in onDownloadStart(). This is replicable only when chrome version 69 is installed on the device.
,
Sep 27
Here is a screenshot. I have overridden onPageStarted and onPageFinished methods which are part of WebViewClient class.
,
Sep 27
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 1
Issue 890295 has been merged into this issue.
,
Oct 1
Tested this issue on latest stable and canary and below are the observations: Changed web-view version to stable#69.0.3497.100 and canary, installed attached apk, clicked on pdf link and below are the observations M-69 stable ========== WebViewDemo(25561): onPageStarted: https://google.com/ WebViewDemo(25561): onPageStarted: https://www.google.com/ WebViewDemo(25561): onPageFinished: https://www.google.com/ /WebViewDemo(25561): onPageStarted: https://www.google.com/search?source=hp&ei=LuyxW-7DHIWelwT2gpRY&ins=false&q=sample+pdf+download&oq=sample+pdf+dnl&gs_l=mobile-gws-wiz-hp. WebViewDemo(25561): onPageStarted: http://www.africau.edu/images/default/sample.pdf WebViewDemo(25561): Download started http://www.africau.edu/images/default/sample.pdf WebViewDemo(25561): onPageFinished: https://www.google.com/search?source=hp&ei=LuyxW-7DHIWelwT2gpRY&ins=false&q=sample+pdf+download&oq=sample+pdf+dnl&gs_l=mobile-gws-wiz-hp. Canary ======== /WebViewDemo(16150): onPageStarted: https://google.com/ WebViewDemo(16150): onPageStarted: https://www.google.com/ /WebViewDemo(16150): onPageFinished: https://www.google.com/ WebViewDemo(16150): onPageStarted: https://www.google.com/search?source=hp&ei=LuyxW-7DHIWelwT2gpRY&ins=false&q=sample+pdf+download&oq=sample+pdf+down&gs_l=mobile-gws-wiz-hp. WebViewDemo(16150): onPageStarted: http://www.africau.edu/images/default/sample.pdf WebViewDemo(16150): Download started http://www.africau.edu/images/default/sample.pdf WebViewDemo(16150): onPageFinished: http://www.africau.edu/images/default/sample.pdf /WebViewDemo(16150): onPageFinished: https://www.google.com/search?source=hp&ei=LuyxW-7DHIWelwT2gpRY&ins=false&q=sample+pdf+download&oq=sample+pdf+down&gs_l=mobile-gws-wiz-hp. In M-69 stable we are not seeing WebViewDemo(16150): onPageFinished: http://www.africau.edu/images/default/sample.pdf. @ chauhan.deepti24: Is this the issue are addressing? Could you please check the issue on latest canary web-view and let us know if this is reproducible or not. Thanks!
,
Oct 9
Yes, this is the issue we are addressing. We should get onPageFinished() once page is done loading or is downloading a file. We tried on canary web-view and issue is replicable even there. Following are the logs: 10-08 17:04:29.771 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: https://google.com/ 10-08 17:04:29.843 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: https://www.google.com/ 10-08 17:04:30.537 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageFinished: https://www.google.com/ 10-08 17:04:39.397 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: https://www.google.com/search?source=hp&ei=Iv-6W7PxKpbe9QOS2aP4Ag&ins=false&q=sample+picture&oq=sample+p&gs_l=mobile-gws-wiz-hp.1.2.0l5.2041.8084..8972...0.0..0.155.1310.0j9......0....1.......0..46j0i131j46i131.xcP6XjBLa1M 10-08 17:04:40.392 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageFinished: https://www.google.com/search?source=hp&ei=Iv-6W7PxKpbe9QOS2aP4Ag&ins=false&q=sample+picture&oq=sample+p&gs_l=mobile-gws-wiz-hp.1.2.0l5.2041.8084..8972...0.0..0.155.1310.0j9......0....1.......0..46j0i131j46i131.xcP6XjBLa1M 10-08 17:04:44.988 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: https://www.google.com/search?ei=z0C7W5TMHIz39QODkZ2IAQ&ins=false&q=sample+pdf&oq=sample+p&gs_l=mobile-gws-wiz-serp.1.4.0i67j0j0i67l2j0.2011.3079..4344...0.0..0.156.813.0j6......0....1.........0i71.rDVaKYJcM9s 10-08 17:04:45.758 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageFinished: https://www.google.com/search?ei=z0C7W5TMHIz39QODkZ2IAQ&ins=false&q=sample+pdf&oq=sample+p&gs_l=mobile-gws-wiz-serp.1.4.0i67j0j0i67l2j0.2011.3079..4344...0.0..0.156.813.0j6......0....1.........0i71.rDVaKYJcM9s 10-08 17:04:47.331 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: http://www.africau.edu/images/default/sample.pdf 10-08 17:04:47.885 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: Download started http://www.africau.edu/images/default/sample.pdf 10-08 17:19:42.030 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: onPageStarted: http://www.africau.edu/images/default/sample.pdf 10-08 17:19:43.230 27288-27288/com.android.uidemo.uidemo I/WebViewDemo: Download started http://www.africau.edu/images/default/sample.pdf We used canary from following link: https://play.google.com/store/apps/details?id=com.chrome.canary We also selected this web view implementation from dev options.
,
Oct 9
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 16
> Ideally we should get callback in onPageFinished() as well before getting callback in onDownloadStart(). That's even worse behavior than today :p The correct behavior is to not generate a onPageStarted either. We are looking at changing onPageStarted for M71, and I expect this to be fixed as well.
,
Dec 14
> The correct behavior is to not generate a onPageStarted either. In my application, onPageStarted and onPageFinished are used to implement the download with the POST method. Because onDownloadStart is not called in the POST method. I can not download with the POST method in M69. Is there any better solution?
,
Dec 14
Could you provide a code sample (ideally a sample application that we can test) of how you are implementing downloads? I don't think we're aware of this at all so I'm not sure what we can suggest without seeing it.
,
Dec 14
Unfortunately, handling POST downloads correctly is simply not possible with existing webview APIs, and this behavior change to onPageStarted is irrelevant. POST requests should not be replayed by a http client, since POST modify server state. Eg you don't want to online submit an order twice to the server. The only way to handle POST downloads correctly is to let webview finish the http request and pass the output to the app in some way; and there is no webview API to do that. I assume what you are doing is replaying the request, which is definitely a bad idea. However onPageStarted does not give you the post body, so I don't even understand how that's possible either. Overall, I think state of post download in webview is broken and there is actually no way to do what you want, even in an incorrect way.
,
Dec 17
I'm implementing it as follows.
1. On the displayed page, execute addEventListener on SUBMIT of FORM as below.
* in Script
document.forms[n].addEventListener('submit', getPostData);
function getFormData(event) {
window.browserFragment.addFormData(...)
}
* in browser fragment
@JavascriptInterface
public void addFormData(...) {
}
2. When SUBMIT is executed, obtain the data of the FORM.
3. When onPageFinish is called, POST again and download the file if the following conditions are satisfied.
* There is form data
* shouldOverrideUrlLoading not called
* doUpdateVisitedHistory not called
* Android 4.4 or higher
I'm aware that this implementation is very strange and will not work correctly in all sites.
However, it is certain that there are many customers who wish to use POST downloads. (like other browsers)
I understand that it is irrelevant to onPageStarted/onPageFinished.
is there any possibility that WebView will support downloading at POST?
If necessary I make a request as another Issue.
,
Dec 17
oh. already exists... https://crbug.com/603014 |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by chelamcherla@chromium.org
, Sep 27