-
Notifications
You must be signed in to change notification settings - Fork 191
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
Warning: Setting up fake worker #136
Comments
You don't need to do anything. If you PDF file is displayed, everything's fine. I'm still trying to find out what these weird messages mean. I'm pretty sure it's a false positive. The default lookup path is also a puzzle. It shouldn't matter because the worker is imported by the I'm keeping the ticket open. It's a good reminder to investigate the topic. |
Hi guys. I have the same problem. I thought pdfjs is doing the heavy load in a webworker for performance increasements. Currently when loading large PDFs the whole web application is blocked by this process which means I cannot interact with any of the other components outside pdfjs. Also the browser brings up the message that a script is taking long time and ask me if I want to kill this script. Shouldn't the webworker solve this problem? And at least the application should stay responsive? |
Sounds like your PDFs are really large. How many megabytes, how many pages are we talking about? |
BTW, it's an interesting theory that the "fake worker" stuff means pdf.js can't setup a worker thread. Maybe it's a hot trace. Thanks for the hint! |
That is one of our test PDFs. Very heavy. |
If I get mozilla/pdf.js#7612 right, the |
You sample file is heavy indeed. My Firefox needed several minutes to open the file (using the native viewer). Adding Angular and a falsy webworker configuration probably doesn't make things better. However, the PDF itself looks really nice. I guess someone (you?) has spent a lot of energy and enthusiasm on it. Awesome! |
Finally, I've found an explanation what the fake worker is: https://www.codeproject.com/articles/568136/porting-and-extending-pdfjs-to-nodejs (scroll down to "Fake worker for web worker"). |
Good news: I've figured out how to use the service worker, and it improves the performance of the PDF viewer a lot. I'm publishing the new version this evening after adding the documentation. Thanks for nudging into the right direction! |
@Catscratch Completely off-topic - but when I opened your test document, this sentence caught my eye: "many say we should pay for the water based on how much we use". I can't believe it: you don't have water meters? They are so common in Europe I thought they're used everywhere. :) |
Since version 1.5.0 you can use the service worker. Currently it's not configurable; it's always Basically, that's the only thing blocking the issue from closing. |
I don't know how to make it run. I also cloned https://github.com/stephanrauh/extended-pdf-viewer-showcase ran Is there another demo project I can use? |
PS: with the new Version 1.5.0 I get the error "ERROR Error: "Uncaught (in promise): Error: Invalid pages rotation angle.". |
Sorry to disappoint you, but it's not my document. It's just a random one from the internet that I use for testing. ;-) |
@philippendrulat I'm still fighting with ES5 support for the PDF worker, so I didn't wan't to commit my code yesterday. Sorry for the inconvenience! BTW: the pdf.worker.js file should be available as localhost:4200/assets/pdf.worker.js. |
@philippendrulat Now it's landed. Please update to version 1.5.1. It fixes the rotation bug and allows you to define a custom path for the pdf worker. I needed that for IE11 support. Updating https://github.com/stephanrauh/extended-pdf-viewer-showcase should give you a working example. It's the same as https://pdfviewer.net. |
Thanks Stephan.
I solved it. I had to modify the scripts node in the angular.json to match the right js file. (es5 or not) to use the correct worker js. Also I had toi add the asset to the angular build.
|
@Catscratch Correct! I tried to document these steps, but I'm not sure I've managed to finish that. If there's something missing in the doc, just tell me. BTW, I'm glad it finally works on your PC! |
@stephanrauh |
Describe the bug
See title. We are using Spring boot for the server and copy our files in the "public" folder. This means we changed angular.json/projects/PROJECT/architect/build/options/outputPath to ../resources/public and serve the "public" folder to the client.
We saw that the default lookup path for the worker is "../build/pdf.worker.js", which seems to not exist.
Do we need to copy the worker.js file to the correct location or do we set the worker.js location in pdfjs directly?
Version info
The text was updated successfully, but these errors were encountered: