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

Use pdf.js inside a Web Worker #558

Closed
3 tasks done
tandat2209 opened this issue Apr 24, 2020 · 2 comments · Fixed by #756
Closed
3 tasks done

Use pdf.js inside a Web Worker #558

tandat2209 opened this issue Apr 24, 2020 · 2 comments · Fixed by #756
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@tandat2209
Copy link

tandat2209 commented Apr 24, 2020

Before you start - checklist

  • I have read documentation in README
  • I have checked sample and test suites to see real life basic implementation
  • I have checked if this question is not already asked

What are you trying to achieve? Please describe.

Using pdf.js inside a WebWorker?

Describe solutions you've tried

I'm using pdf.js to generating images from pdf documents .

It works OK. But during the generating process, it's blocking the main thread which is causing some UI issues.

So then I want to move all the logic to a Web Worker to free the main thread.

But when running in the web worker, there is an error:

pdf.js:11210 Uncaught (in promise) Error: Setting up fake worker failed: "webpack_require(...).ensure is not a function".

It's thrown from this function setupFakeWorkerGlobal

My guess is it can not load the workerSrc, so it has to use fake worker with throw error. :(

I'd appreciate any helps.

Environment

  • Browser: Chrome 81
  • React-PDF version: 4.1.0
  • React version: 16.8.6
@tandat2209
Copy link
Author

I asked a question in StackOverflow here: https://stackoverflow.com/questions/61409061/using-pdf-js-inside-a-webworker

@wojtekmaj wojtekmaj added help wanted Extra attention is needed question Further information is requested labels Apr 27, 2020
@wojtekmaj
Copy link
Owner

Please kindly check React-PDF v5.3.0-beta.2, in which improvements regarding loading PDF.js worker were made.

These changes should result in 10-15 seconds faster Webpack builds, as well as you should be able to use Webpack entry file in Create-React-App, without the need of using external CDN for hosting worker.

Let me know what you think in #748!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants