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

Issue 623051 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 667199
Owner: ----
Closed: Dec 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 1
Type: Bug-Regression



Sign in to add a comment

PDF files won't open in or save in iBooks or third party apps

Reported by nyracing...@gmail.com, Jun 24 2016

Issue description

Steps to reproduce the problem:
1. Find a website with a PDF
2. Bring up "Open in" option. Select "Copy to iBooks" or "Copy to Notability"
3. When iBooks opens, an error message "Cannot Open Document" appears. When Notability opens, the program does not open the PDF.

What is the expected behavior?
iBooks and Notability should open the PDF file immediately with zero issues.

What went wrong?
Recent versions of Chrome for iOS since around Christmas 2015 will not open or save PDF files to either my iBooks or Notability app. I have no idea what has gone wrong. It is not an iPad issue since I am able to perform said functions using Apple's Safari browser.

Did this work before? Yes It worked around Christmas (December) 2015.

Chrome version: 51.0.2704.104  Channel: stable
OS Version: 9.3.2 (13F69)
Flash Version: 

PDF files open and save in iBooks and Notability when accessed with Safari
 
image.png
1.6 MB View Download
image.png
1.7 MB View Download
Owner: gch...@chromium.org
Status: Assigned (was: Unconfirmed)
I just tested using this pdf: http://www.pdf995.com/samples/pdf.pdf and it worked. Is this a site you have to log into?
Verified in 53.02784.0 canary, iPhone 6 iOS 9.2.1, iPad mini 4  9.2.1
issue is not reproducible.
It seems like it could be an issue with PDFs that have security or copy
protection. The PDF in question was from Daily Racing Form (drf.com). I
tried numerous other PDF files and was unable to replicate this issue.
However, when it is something copy protected, it won't work. However, it is
funny that the very same file will open in these apps when opened through
Safari.
Hi gchatz, This issue looks similar to issue 609193, issue 462384, please confirm.
Has gchatz figured out this issue yet?


open in or save in iBooks or third party apps

<https://bugs.chromium.org/p/chromium/issues/detail?id=623051#c5>

confirm.

<https://bugs.chromium.org/hosting/settings>

Comment 7 by gch...@chromium.org, Jul 12 2016

This is different from issue 609193 as the failure occurs in iBooks as opposed to during the download. 

I tested a variety of protected PDFs, and have not been able to repro the issue: (http://www.novapdf.com/kb/pdf-example-files-created-with-novapdf-138.html and http://www.win2pdf.com/products/samples.htm)

Are you able to provide a test case aside from drf.com? Looks like that site requires payment to access the pdf. 
I tried opening my tax returns via H&R Block website. Same outcome. Not
submitting that due to sensitive information.

Comment 9 by gch...@chromium.org, Jul 25 2016

Did iBooks say "Cannot open document" or did this error come up: "“The file could not be downloaded at this time”?
iBooks said "Cannot Open Document" when importing PDF from Chrome... yet
when I use Safari and import a PDF to iBooks, it works. It's a browser
issue.
I was wondering specifically what error message came back when you tried H&R Block. Was it "Cannot open document", or something else, since the failure could have different causes.

We have tried protected PDFs on a variety of websites, and encrypted PDFs made by Adobe Acrobat Pro, and we are not able to reproduce the "Cannot open document" error in iBooks. So, any information, or if you can provide a sample PDF document where the "Cannot open document" error occurs, would be helpful. 
Go to this link:
http://www.brisnet.com/cgi-bin/briswatch.cgi/public/GaryContessa/CONTESSA+GARY+C/9999/summary.html

Click on any link that says "Ultimate PPs"

Bring up the "Open In..." option and select "Copy to iBooks".

I get "Cannot Open Document Unable to Open "bw_pdf_viewer"

This is a free website. No login required.

I have tried replicating this error in the Safari browser that comes with
the iPad and the document opens no problem.
I downloaded Adobe Reader to the iPad. When I use Chrome and attempt to
open a secure PDF in Adobe Reader, I get the message "The document cannot
be opened because it is not a valid PDF document."

I have had this ticket open for over a month and nobody can debug this
issue? It's a Chrome issue for sure. I don't have this issue with Safari or
other web browsers. It's not an individual iPad issue because I have done
clean reinstalls of iOS three times already.

On Friday, July 1, 2016, olivierr…@chromium.org via Monorail <
monorail@chromium.org
<javascript:_e(%7B%7D,'cvml','monorail@chromium.org');>> wrote:
Cc: cma...@chromium.org
Labels: M-55
I was able to repro with the test case from brisnet.com on an iPhone 6s. 

cmasso: Could testers look to see if this repros on all devices/iOS versions?
Cc: madhusudhan@chromium.org
Tested on iPhone 6(10.0), iPad Air(9.3.5), iPad Mini(10.0), iPhone 6S Plus(9.3.4). Able to reproduce the issue. 
Opening PDF and selecting 'Open in' and then to 'Copy to iBooks' displays the error 
"Unable to Open "bw_pdf_viewer""
I was able to reproduce the issue with the new iOS10 operating system.
Has there been any progress in debugging this issue?
Cc: pkl@chromium.org
If I download the file http://www.brisnet.com/php/bw_pdf_viewer.php?track=BEL&race=1&param1=133056&param2=690&param3=1380  (from the link in comment 12) using URLFetcher, the downloaded file is corrupted. 

I tested by trying to download the file in iOS Simulator (using both the code in OpenInController and custom code). When I try to open the PDF that is saved to the tmp directory, it is unable to be opened (see screenshot).

So, it seems to be an error in URLFetcher. pkl, do you know to whom this bug should be sent? 
Screen Shot 2016-10-17 at 5.21.49 PM.png
10.4 KB View Download
Perhaps it is failing because it is a dynamically generated pdf. 
Cc: -pkl@chromium.org gch...@chromium.org
Owner: pkl@chromium.org
Sending to pkl to add bug to networking triage, since bug is in URLFetcher. 
Any progress on this issue?
Is there any progress in debugging this issue? I don't get why it has taken
so long to debug an issue that isn't an issue in Safari.

Comment 24 by pkl@chromium.org, Dec 10 2016

Cc: mef@chromium.org pkl@chromium.org
Components: Internals>Network
Labels: -Pri-2 -M-55 Pri-1
Owner: ----
Status: Untriaged (was: Assigned)
+mef to see if he knows if anyone has time to look at this.

nyracingfan: Sorry that this takes a while. Safari being a system-provided app can access APIs that other apps may not have access to.

Comment 25 by mef@chromium.org, Dec 11 2016

Components: UI>Browser>Downloads
I'll be on bug triage duty 12/14-12/15 and could probably take a look.

- Is it reproducible in the simulator?

- How is corrupted downloaded file different from not corrupted?

- I've noticed that links from Comment 12 are opening with url with 'bw_pdf_viewer.php' part of address and I'm wondering whether Chrome passes that file name to iBooks and iBooks doesn't recognize that it is PDF inside.

Comment 26 by mef@chromium.org, Dec 11 2016

Also, I don't see 'Open In' option on iPhone in M54, is it specific to iPad or is it something that was removed?
Yes, it is reproducible in the simulator.

If I download the given PDF in a simulator, and then try to open it on the Mac from the simulator app's tmp directory, the pdf fails to open. If I do this with a typical pdf, the pdf opens successfully.

The code relevant to this is in OpenInController.mm. The code there passes the file path gotten from the URLFetcher using GetResponseAsPath to the document interaction controller (which sends it to iBooks). The document interaction controller's UTI is set to com.adobe.pdf, so a PDF is expected by iBooks.

But, since the PDF in the tmp directory is corrupted, it seems that the corruption happens before iBooks gets involved.

You can see the Open In option by navigating to a PDF, and tapping on the screen.


Components: -Internals>Network

Comment 29 by mef@chromium.org, Dec 13 2016

gchatz, thanks!

I've reproduced it on the device and debugged in the simulator. The problem is caused by the fact that OpenInController is trying to download the pdf again in startDownload, and at that point it doesn't have the referrer and whatever else is needed by the server, so the response saved to file is plain text saying 'Invalid Parameter':

$ cat /Users/mef/Library/Developer/CoreSimulator/Devices/A2741C50-3EFF-41D3-A05F-9240F332E205/data/Containers/Data/Application/FDB06231-7043-411F-A932-657BA814A64E/tmp/OpenIn/bw_pdf_viewer.pdf

Invalid Parameter

You get the same response if you try to follow the link http://www.brisnet.com/php/bw_pdf_viewer.php?track=BEL&race=1&param1=133056&param2=690&param3=1380 specified in comment 19 or just try to open any link from http://www.brisnet.com/cgi-bin/briswatch.cgi/public/GaryContessa/CONTESSA+GARY+C/9999/summary.html in incognito tab.

This is NOT an error in URLFetcher.


That link is old. Try this:

http://www.brisnet.com/php/bw_pdf_viewer.php?track=DED&race=1&param1=137088&param2=828&param3=1380

On Dec 13, 2016 5:35 PM, "m… via monorail" <monorail+v2.846173693@
chromium.org> wrote:
Try this.

http://www.brisnet.com/cgi-bin/briswatch.cgi/public/SpendThrift/COURT+VISION/2005/summary.html

Click on any link saying Ultimate PPS. You can't copy/paste link or it will
fail.

Comment 32 by mef@chromium.org, Dec 13 2016

From link http://www.brisnet.com/cgi-bin/briswatch.cgi/public/SpendThrift/COURT+VISION/2005/summary.html right-clink on any link saying 'Ultimate PPS' and click 'Open link in incognito window'. 

Observe 'Invalid Parameter'.

Comment 33 by mef@chromium.org, Dec 13 2016

The 'Invalid Parameter' is not specific to iOS, I'm getting it on Linux.

Comment 34 by mef@chromium.org, Dec 13 2016

I would *speculate* that problem on iOS is caused by the fact that Chrome doesn't have access to files downloaded by WkWebView, hence it has to re-download them, but it doesn't have sufficient context to pass to server.

pkl@, does it sound right?

Comment 35 by mef@chromium.org, Dec 13 2016

Mergedinto: 667199
Status: Duplicate (was: Untriaged)

Comment 36 by pkl@chromium.org, Dec 14 2016

Do we know how is the request authenticated? Is it based on cookies (I would assume so) or something else?

If this is due to missing cookies, then it is indeed correct that it is due to a system limitation.

Comment 37 by mef@chromium.org, Dec 15 2016

Labels: Needs-Feedback
nyracingfan@ - do you know anything about the www.brisnet.com server?
pkl@ - Is there anything that can be provided to UrlFetcher from WkWebView? 
For example, is it possible to get referrer?
Let me explain the issue one more time: If I go to Brisnet.com and click a
link to download a PDF (I go through a 3rd party site since it's free...
http://trks2day.com/trks2day.html and then click on R01, R02, etc to take
me to a Brisnet.com page where I can click on an Ultimate PPs link for a
specific file), it will display on the Chrome Browser screen. However, if I
attempt to import the open file to either Notability or iBooks, I get an
error. I never had this issue in 2015 with older versions of Chrome. It
started late 2015 and exists to this day.

Comment 39 by mef@chromium.org, Dec 19 2016

Yes, as it is explained in duplicate  issue 667199 : "This is a known problem with WKWebView implementation on iOS. When cookies are required to download the PDF file, Chrome fails because WKWebView does not have access to the cookies."

It used to work before 2015 because Chrome was using UIWebView, which allowed use  of Chrome Network stack and was able to pass file shown on the screen to another app.

With WkWebView Chrome doesn't have access to actual displayed PDF file and has to download it again, but because it doesn't have access to cookies used by WkWebView, it cannot attach them to the request, and server returns 'Invalid Parameter' response with Http code 200, which indicates that download has succeeded and file is good for passing to external app.


So is there a fix or am I basically out of luck?

Comment 41 by mef@chromium.org, Dec 19 2016

I think your best course of action is to ask maintainers of http://www.brisnet.com to check why their server is returning 'Invalid Parameter' to these requests and see if they can fix it.
This happens when I download files from DRF.com and TimeformUS.com through
Chrome. It's not just a Brisnet.com issue. I prefer using Chrome over
Safari but when it comes to downloading these files and attempting to
import to Notability or iBooks with Chrome, it fails. If I could, I would
upload a video demonstrating what I'm doing with all these sites to show
where it fails each time.
I am uploading a video to my Google Drive. I will send the link once it
uploads. This will replicate the failure on both DRF.com and TimeformUS.com
and trks2day.com 3rd party. When I download directly from the Brisnet.com
site (which is different than trks2day.com where we have been testing), I
have no Chrome issues with Notability or iBooks.

This hopefully will shed more light.
https://drive.google.com/open?id=0B5rBgi1_6W93bmxEeGxkOXJtSlU

The link to my video capturing the issue with these PDFs.
(Don't mind the 3 year old in the background lol)

Comment 45 by mef@chromium.org, Dec 20 2016

Thanks for the video, the 3 year old is definitely the curious kind. :)

Example with www.drf.com and trks2day.com definitely confirm that this is duplicate of  issue 667199 . The login in browser window allows you to view PDF in Chrome, but in order to open it in external app it needs to be downloaded again, but Chrome doesn't have authorization cookie obtained by WkWebView.

I'm pretty sure that if you try to open downloaded file in some generic file management app like Google Drive, then you'll see that it has non-PDF content.

At this point this is system limitation, which requires Apple to fix iOS side: https://bugs.webkit.org/show_bug.cgi?id=140191
Thanks for your help and I'll check into that link.

Sign in to add a comment