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

Chrome 39 seems to incorrectly cache RangeResponses #5512

Closed
CodingFabian opened this issue Nov 27, 2014 · 16 comments
Closed

Chrome 39 seems to incorrectly cache RangeResponses #5512

CodingFabian opened this issue Nov 27, 2014 · 16 comments

Comments

@CodingFabian
Copy link
Contributor

Message: Unexpected server response (206) while retrieving PDF.

It looks like either PDF.js does something strange, or there is a regression in Chrome 39 (Version 39.0.2171.65 (64-bit)).
Sometimes I am getting a partial response for the first request. If I have dev-tools with the cache override open, this does not happen at all.
If I allow caching then chrome seems to mix up the responses sometimes.

Might be a regression of the streaming implementation?
Right now I need to add Chrome 39 to checkRangeRequests() in Compatibility.js

@CodingFabian
Copy link
Contributor Author

it even reproduces locally on the tracemonky paper.

@CodingFabian
Copy link
Contributor Author

Here is how a clean cache load looks like
screen shot 2014-11-27 at 13 40 57
And here is how then a reload (keeping the cache, e.g. enter in the url bar) looks like
screen shot 2014-11-27 at 13 41 23

@Rob--W
Copy link
Member

Rob--W commented Nov 28, 2014

@CodingFabian Could you paste the headers of an allegedly cached response?
And also provide a script that starts a local server with the caching headers that you used to generate the screenshots.

@CodingFabian
Copy link
Contributor Author

@Rob--W no need for a script. this is default behaviour of pdf.js here.
checkout master and run node make server

Here the first request when working

Remote Address:127.0.0.1:8888
Request URL:http://localhost:8888/web/compressed.tracemonkey-pldi-09.pdf
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:localhost:8888
Pragma:no-cache
Referer:http://localhost:8888/src/worker_loader.js
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
Response Headersview source
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:1016315
Content-Type:application/pdf
Date:Mon, 01 Dec 2014 11:40:01 GMT

and here when not:

Remote Address:127.0.0.1:8888
Request URL:http://localhost:8888/web/compressed.tracemonkey-pldi-09.pdf
Request Method:GET
Status Code:206 Partial Content
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Host:localhost:8888
Range:bytes=0-786431
Referer:http://localhost:8888/src/worker_loader.js
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
Response Headersview source
Accept-Ranges:bytes
Connection:keep-alive
Content-Length:786432
Content-Range:bytes 0-786431/1016315
Content-Type:application/pdf
Date:Mon, 01 Dec 2014 11:41:32 GMT

so from what it looks like there is already something odd when the very first request is visible in the console.

@yurydelendik
Copy link
Contributor

@CodingFabian I had some time to bisect:

You are probably looking for a change made after 292738 (known good), but no later than 292753 (first known bad).
NOTE: There is a Blink roll in the range, you might also want to do a Blink bisect.
CHANGELOG URL:
  http://build.chromium.org/f/chromium/perf/dashboard/ui/changelog.html?url=/trunk/src&range=292738%3A292753

Which kinda points to https://chromium.googlesource.com/chromium/src.git/+/439a05cd87fe1f880b896bd7b154454299355899%5E%21/

https://code.google.com/p/chromium/issues/detail?id=407923

@yurydelendik
Copy link
Contributor

@CodingFabian
Copy link
Contributor Author

yeah good find. though quite annoying, because pdf.js should then disable ranges for confirmed chrome versions (39?) (similar to the safari disable)

@yurydelendik
Copy link
Contributor

pdf.js should then disable ranges for confirmed chrome versions (39?) (similar to the safari disable)

Yes, we should, until the issue will be sorted out, at least for versions 39-41. PR is welcome. STR in the chromium issue shall be corrected as well.

@CodingFabian
Copy link
Contributor Author

Ok, will do that.

@CodingFabian
Copy link
Contributor Author

while i was waiting for a clearer confirmation from chrom(e|ium), I think its safe to assume we should disable range requests for chrome > 39.

@Rob--W
Copy link
Member

Rob--W commented Dec 30, 2014

@CodingFabian Wouldn't it be better to detect response code 206 and handle that appropriately instead of disabling range requests all together?

@CodingFabian
Copy link
Contributor Author

that would be better and quite complicated. for safari and android we already disable it globally because the quirks are complicated to detect.
Its broken in chrome 39+ until fixed and its easy to turn it off. And when looking at the chrome bugs, its even not 100% clear whats broken, so I would not know how we would actually work around that.

CodingFabian added a commit to CodingFabian/pdf.js that referenced this issue Dec 30, 2014
Disabling Range Support for Chrome 39 and above, due to regression in
Chromium. Will be enabled once a fix version is confirmed.

* https://code.google.com/p/chromium/issues/detail?id=444659
* https://code.google.com/p/chromium/issues/detail?id=442318
@Rob--W
Copy link
Member

Rob--W commented Dec 30, 2014

Disabling range requests has implications for perceived performance, especially for huge documents and/or slow connections. That's why I'm opposed to disabling range requests unless there is no alternative.

The first request is only used to get the file's metadata, and if range requests are supported, the request is aborted. However, due to the fact that Chrome 39+ replies with status 206 instead of 200, PDF.js bails out and reports an error. Since the metadata is available (range requests is supported as implied by status code 206, and also content-length), I think that it is feasible to reliably detect this bug and treat it appropriately (e.g. continue fetching ranges).

@CodingFabian
Copy link
Contributor Author

feel free to make a PR.
I am pretty aware of the implications. I was actually surprised nobody besides noticed the problem so far. We got quite a few customer complaints when they upgraded to chrome 39.
I fear in real deployments of custom pdf.js versions, the server does not support range requests.
right now we deployed a quick fix to our load balancer disabling range requests, which has the implications you describe.

MY PR does a nicely coupled clean hotfix in compatibility.js, which at least makes pdf.js work again :)

Rob--W added a commit to Rob--W/pdf.js that referenced this issue Dec 30, 2014
Use Content-Range header instead of Content-Length when the
response has status code 206, to work around issue mozilla#5512,
which is caused by a bug in Chrome (since version 39):
https://code.google.com/p/chromium/issues/detail?id=442318
@Rob--W
Copy link
Member

Rob--W commented Dec 30, 2014

@CodingFabian See PR #5603.

Rob--W added a commit to Rob--W/pdf.js that referenced this issue Dec 30, 2014
Use Content-Range header instead of Content-Length when the
response has status code 206, to work around issue mozilla#5512,
which is caused by a bug in Chrome (since version 39):
https://code.google.com/p/chromium/issues/detail?id=442318
Rob--W added a commit to Rob--W/pdf.js that referenced this issue Jan 6, 2015
Use Content-Range header instead of Content-Length when the
response has status code 206, to work around issue mozilla#5512,
which is caused by a bug in Chrome (since version 39):
https://code.google.com/p/chromium/issues/detail?id=442318
yurydelendik added a commit that referenced this issue Jan 6, 2015
Use Content-Range instead of Content-Length #5512
joelkuiper added a commit to joelkuiper/pdf.js that referenced this issue Jan 21, 2015
* 'master' of https://github.com/mozilla/pdf.js: (88 commits)
  Amend the docs for |disableAutoFetch| to mention that streaming must also be disabled
  Chrome extension: Add options page
  Prevent setting |isStandardFont| to |undefined| for non-embedded fonts
  Attempt to display the File size quicker in the Document Properties dialog (PR 5554 followup)
  Fix thumbnail scaling regression for files with different page sizes (issue 5637)
  Base64 example and be more flexible what type of data is passed.
  Add marker segment (PLT, PLM) and refactor TLM
  Refactor searching for end of inline (EI) JPEG image streams
  Modify |getUint16| to correctly handle missing data in Stream, DecodeStream and ChunkedStream
  Fixes B2G file open sequence.
  Whitelists 'tel' schema.
  Fix lint error: "test/webserver.js: line 177, col 106, Line is too long."
  Adds encoding for test server index page.
  Move the |pagerendered| event to pdf_page_view.js
  Add a |textlayerrendered| event
  Version 1.0.1040
  Use Content-Range instead of Content-Length mozilla#5512
  Refactors getDocument and adds PDFDataRangeTransport.
  Add missing comma to German add-on description
  Implement guards for stringToBytes and bytesToString
  ...
speedplane pushed a commit to speedplane/pdf.js that referenced this issue Feb 24, 2015
Use Content-Range header instead of Content-Length when the
response has status code 206, to work around issue mozilla#5512,
which is caused by a bug in Chrome (since version 39):
https://code.google.com/p/chromium/issues/detail?id=442318
speedplane pushed a commit to speedplane/pdf.js that referenced this issue Feb 24, 2015
CodingFabian added a commit to CodingFabian/pdf.js that referenced this issue Apr 29, 2015
Disabling Range Support for Chrome 39 and 40, due to regression in
Chromium. https://crbug.com/442318
timvandermeij added a commit that referenced this issue Apr 30, 2015
@timvandermeij
Copy link
Contributor

Fixed by #5598.

joelkuiper added a commit to joelkuiper/pdf.js that referenced this issue May 5, 2015
* 'master' of https://github.com/mozilla/pdf.js: (51 commits)
  Revert mozilla#5603 regarding Chrome range request bug
  Disable Range Support for Chrome 39+40 (mozilla#5512)
  Prevent Firefox from warning about |unreachable code after return statement|
  Simplify document properties field logic
  Enable linting of Firefox specific code in viewer.js
  Group public/private methods and add comments
  Clarify bug reporting with regards to providing a pdf
  Add a reduced test-case for issue 5801
  Attempt to infer if a CMap file actually contains just a standard `Identity-H`/`Identity-V` map
  Refactor PDFDocumentProperties to be more class-like
  Rename DocumentProperties to PDFDocumentProperties
  Remove no longer needed hacks that enable spacebar scrolling in Firefox (issue 3498)
  Preface all "fullscreen" CSS rules with a |pdfPresentationMode| class, and add it to the |viewerContainer| while Presentation Mode is active
  Refactor PDFPresentationMode to be more class-like
  Re-ordering the PDFPresentationMode code so that the "public" functions are placed towards the top of the file
  Initial refactoring of the PDFPresentationMode code
  Rename the presentation_mode.js file and adjust the function names
  Refactor the options passed to |PresentationMode.initialize| and clean-up some code in viewer.js and presentation_mode.js
  Move the PresentationMode-specific scrollWheel code from PDFViewerApplication
  Break dependencies between PresentationMode and other code, and add PresentationMode related utility methods to PDFViewer
  ...
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

5 participants