mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.33k stars 9.97k forks source link

IE 11 document window does not respond to events during printing as PDF #6567

Closed jokesmith closed 8 years ago

jokesmith commented 8 years ago

Software used:

To reproduce:

Rob--W commented 8 years ago

You do see a dialog with a progress bar while the print job is generated, right?

jokesmith commented 8 years ago

I do see the progress bar immediately after clicking the print icon. I also updated the instructions for reproducing the issue to indicate so.

Rob--W commented 8 years ago

Print dialogs are supposed to be modal, it's normal that you cannot interact with the page until the dialog is closed. I think that you'll encounter the same issue if you take any big document and try to print it using your steps.

jokesmith commented 8 years ago

I understand the dialog is modal, however, once the file name to save as is selected and "Save" is clicked, the document can be scrolled and resized in Firefox while the PDF is being created; IE 11 does not respond to these events.

Rob--W commented 8 years ago

Could you check whether the responsiveness issue is a PDF.js-only thing (or does it also happen if you try to print other big pages? If you need a huge page for testing, try http://www.w3.org/TR/html5/)

I cannot test on IE11 at the moment, so here is some technical background (perhaps you can identify the issue yourself after knowing these facts):

Firefox has a special API (mozPrintCallback) that can be used to send one page at a time to a printer. This allows PDF.js to be efficient.
IE does not have this API, and we use the beforeprint event to set up all canvases and the afterprint event to detect when print request has finished so that the viewer can be restored (https://github.com/mozilla/pdf.js/blob/master/web/mozPrintCallback_polyfill.js).

PDF.js does some bookkeeping before and after the print task is finished: beforePrint: https://github.com/mozilla/pdf.js/blob/aae82ec4c5c16be77de2e4429b6fd00aade82cc6/web/viewer.js#L1140-L1215 afterPrint: https://github.com/mozilla/pdf.js/blob/aae82ec4c5c16be77de2e4429b6fd00aade82cc6/web/viewer.js#L1230-L1243

jokesmith commented 8 years ago

To try the huge page at http://www.w3.org/TR/html5/, I first went to the HTML page, then printed it to Adobe PDF and saved it. I then loaded the saved PDF into the pdf.js viewer and printed it to Adobe PDF in both Firefox 41.0.2 and IE 11 and experienced the exact same results as with the demo document. I probably should have mentioned it earlier but I do have other "private" large documents that I first experienced the problem with, but wrote the issue up using the demo document as it can be seen with that test case also.

Rob--W commented 8 years ago

@jokesmith

I mean if you print normally from http://www.w3.org/TR/html5/ (e.g. print, save as PDF), can you still scroll on the page while the print result is generated? (if yes, then it is not a problem with PDF.js; if not, then (todo))

  • Select Adobe PDF as the printer
  • The "Save PDF File As" dialog will pop up. Note that if you move this dialog window around the main document window does not redraw even if the dialog is moved over and out of the "main" document window.
  • Select a file name to save as and click Save. Note that the main document window is unresponsive to scrolling, clicks, etc. while the PDF is being generated/saved, i.e. while the Creating Adobe PDF progress window is showing.
  • Once the PDF is created, the main document window is now responsive.
jokesmith commented 8 years ago

I tried printing normally from http://www.w3.org/TR/html5/ (e.g. print, save as PDF). I ran the test 5 times as the document is faster to print, but my belief is that this page was unresponsive meaning I could not scroll in IE 11 while the PDF was being generated. I will need to search around for more content so I can run the test w/o a doubt.

jokesmith commented 8 years ago

One item to mention is that when I was debugging before/afterPrint last week, I noticed that in IE 11 the afterPrint handler is called immediately after the "Preparing document for printing" operation is complete, i.e. PRIOR to the printer selection dialog popping up.

jokesmith commented 8 years ago

I just tried printing to PDF on http://www.deepskyfrontier.com/ and www.onemilescroll.com/ (give them some time after you select the printer !) with IE 11. Both documents were responsive with PDF.js out of the picture.

Rob--W commented 8 years ago

Thanks for checking (if you want a bigger page for testing, try https://html.spec.whatwg.org/).

jokesmith commented 8 years ago

With https://html.spec.whatwg.org/ in IE 11, printing as a PDF, the web page was responsive while the PDF was being created, again, independent of PDF.js.

jokesmith commented 8 years ago

Hmmm, not sure how I accidently closed the issue, but it is definitely still open.

Also, we are getting reports of this in Chrome and FF as well, it's very intermittent though.

jokesmith commented 8 years ago

Hi, wondering if there is anything else I can do to in terms of debugging or test cases for you ? thanks.

yurydelendik commented 8 years ago

Couple of questions:

jokesmith commented 8 years ago

I am running Windows 7 Enterprise SP 1 64-bit, 24 GB RAM, 3.47GHz, over 100 GB free disk.

IE 11 results:

I only see the problem with Adobe PDF printer. Printing to Microsoft XPS document writer and a hardware printer are fast.

CPU of acrobat distiller is under 7-13 % when running and running around 20K RAM.

I don't see any big files created, "C:\Users\bpeterse\AppData\Local\Temp\Acrobat Distiller 11" contains some temp directories with relatively small files.

Chrome 46.x results:

It all happens quickly. The distiller seemed to use the same relative amount of resources.

Firefox 42.0 results:

Though slower than chrome and faster than IE, the main document is still responsive to scrolling. The distiller seemed to use the same relative amount of resources.

jokesmith commented 8 years ago

One other item to mention. When I run one of my own PDF test cases thru, I see the following resulting PDF file sizes:

Chrome: 2741 KB Firefox: 5745 KB IE 11: 2900 KB

Not sure what is expected ?

yurydelendik commented 8 years ago

I'm afraid there is nothing we can do about Adobe PDF printer blocking IE11 UI thread -- PDF.js has no control over web browsers. Closing as won't fix.

Try to create a web pages with dozen of large HTML5 canvases (about 2000x3000) and print them in IE11 (I cannot reproduce the issue since I don't have Adobe PDF printer installed). Something like http://jsbin.com/gujepuyici/1 -- this might help to report this to the upsteam.