Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing in Safari #3352

Closed
ykessler opened this issue Jun 8, 2013 · 13 comments
Closed

Failing in Safari #3352

ykessler opened this issue Jun 8, 2013 · 13 comments

Comments

@ykessler
Copy link

ykessler commented Jun 8, 2013

Our sample PDF files are failing to load in Safari, whether served locally on MAMP or from our remote test server.

(Using latest pdf.js build (PDFJS.version = '0.8.229'; PDFJS.build = 'b996e1b';) on Safari (5.1.9 - 6.0.4) Mac OSX Snow Leopard + (10.6.8 - 10.8.3))

EXAMPLE:

This is an example of the demo code served from our server with a sample PDF. Works on Chrome/FFox but not Safari:
http://test.appgrinders.com/pdf_js/test.html

Console output:

Warning: Setting up fake worker.
Error: Invalid XRef stream
(while reading XRef): Error: Invalid XRef stream
pdf.js:850undefined
Warning: Indexing all PDF objects
Error: Invalid XRef stream
(while reading XRef): Error: Invalid XRef stream
pdf.js:850undefined

Sample PDFs tested (They were all served from our server):

FAILS IN SAFARI:
http://samplepdf.com/sample.pdf
http://forums.adobe.com/servlet/JiveServlet/previewBody/2041-102-1-2139/Sample.pdf
https://github.com/prawnpdf/prawn/raw/master/data/pdfs/form.pdf

WORKS IN SAFARI: (Only pdf.js's own PDF file actually works)
http://cdn.mozilla.net/pdfjs/helloworld.pdf

(All the tested files load fine in Chrome/FFox/Android)

@ykessler
Copy link
Author

Can anyone confirm this issue?

@brendandahl
Copy link
Contributor

You should include compatibility.js which will disable range request loading for safari. See #3315

@ykessler
Copy link
Author

Hi Brendan,

Just tried including compatibility.js per your suggestion, but it's having no effect - still getting Invalid XRef stream error:

Warning: Setting up fake worker.
compatability.js:453Range requests are disabled for safari.
Error: Invalid XRef stream
(while reading XRef): Error: Invalid XRef stream
pdf.js:850undefined
Warning: Indexing all PDF objects
Error: Invalid XRef stream
(while reading XRef): Error: Invalid XRef stream
pdf.js:850undefined

@brendandahl
Copy link
Contributor

Make sure you clear the safari cache and restart it. There still may be bad cached requests in there.

@ykessler
Copy link
Author

Not a caching issue- we're trying this on multiple safari browsers, some for first time. None are working. We've reproduced the error on Safari versions 5.1.9 - 6.0.4, for OSX 10.6.8 - 10.8.3.

The test link is here: http://test.appgrinders.com/pdf_js/test.html
You can try it for yourself, it won't work.

@brendandahl
Copy link
Contributor

Looks like we aren't disabling range requests early enough. The code to disable is running after the document is being fetched.

@yurydelendik
Copy link
Contributor

Let's try 152e376

@ykessler
Copy link
Author

Still failing: http://test.appgrinders.com/pdf_js/test.html

Warning: Setting up fake worker.
compatability.js:452Range requests are disabled for safari.
(while reading XRef): TypeError: 'null' is not an object (evaluating 'this.xref.fetch')
pdf.js:850undefined
Warning: Indexing all PDF objects
pdf.js:850undefined

@ddkilzer
Copy link

I believe the WebKit bug that tracks the range-request issue is:

[Mac] XHR range requests are broken (Test failure: http/tests/xmlhttprequest/range-test.html)
https://bugs.webkit.org/show_bug.cgi?id=82672

Comment #4 on that bug notes a workaround:

A workaround for this bug is to suppress caching for each XHR with a Range header, using:
xhr.setRequestHeader("Cache-control", "no-cache");

I would suggest trying that to see if it fixes the issue, rather than disabling range requests altogether for Safari.

@brendandahl
Copy link
Contributor

In my testing there were still issues with the cache disabled.

@ykessler
Copy link
Author

I've figured out what how to get things working in Safari. The PDFJS.workerSrc = 'worker_loader.js'; assignment must be present! I had been using the demo code from http://jsbin.com/pdfjs-helloworld-v2/1/edit, which doesn't use it, but once I added it, all our examples are now working.

See this answer for some more detail:
http://stackoverflow.com/a/17126261/165673

@yurydelendik
Copy link
Contributor

@ykessler, can we close the issue?

Does the example work with recent compatibility.js ?

@ykessler
Copy link
Author

@yurydelendik- I don't think the compatibility.js changes had an effect either way, though it does work with the latest. As I mentioned above, the keys to finally get things working in Safari was:

1- Including compatibility.js
2- Including the line PDFJS.workerSrc = 'worker_loader.js'.

This is no longer an issue for me- can be closed. Thanks-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants