New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 889387 link

Starred by 4 users

Issue metadata

Status: Verified
Owner:
Closed: Dec 14
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug-Regression



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 description

Steps 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:
 
Labels: Needs-triage-Mobile
Cc: chelamcherla@chromium.org
Labels: Needs-Feedback Triaged-Mobile
@chauhan.deepti24: Could you please let us know where to check onPageFinished() callbacks. Please provide sample app and screencast on reproducing the issue.

Thanks!
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.
WebViewIssue.apk
1.5 MB Download
Here is a screenshot. I have overridden onPageStarted and onPageFinished methods which are part of WebViewClient class.
Screen Shot 2018-09-27 at 8.15.31 PM.png
166 KB View Download
Project Member

Comment 5 by sheriffbot@chromium.org, Sep 27

Labels: -Needs-Feedback
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
Issue 890295 has been merged into this issue.
Cc: -chelamcherla@chromium.org sindhu.chelamcherla@chromium.org boliu@chromium.org
Components: Mobile>WebView
Labels: Needs-Feedback
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!
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.
Project Member

Comment 9 by sheriffbot@chromium.org, Oct 9

Cc: chelamcherla@chromium.org
Labels: -Needs-Feedback
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
Owner: boliu@chromium.org
Status: Assigned (was: Unconfirmed)
> 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.
> 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?

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.
Status: Verified (was: Assigned)
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.
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.

oh. already exists...  https://crbug.com/603014 

Sign in to add a comment