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

Very high memory usage compiling mozilla/PDF.js #10875

Closed
abonckus opened this issue Dec 17, 2019 · 5 comments · Fixed by #10885 or #10890
Closed

Very high memory usage compiling mozilla/PDF.js #10875

abonckus opened this issue Dec 17, 2019 · 5 comments · Fixed by #10885 or #10890
Assignees
Labels
area: perf Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core

Comments

@abonckus
Copy link

Bug Report

Current Behavior
When running npm start or npm run build, while pdf.js is used in create-react-app project, memory usage seems to skyrocket to unreasonable amounts and fail with "JavaScript heap out of memory" error.
unreasonable memory usage
NPM Error
I've reported it to PDF.js guys, and they found that ejecting and downgrading babel from 7.7.0+ to 7.6.4 seems to fix the issue so they think it must be regression issue with Babel. The issue can be reproduced in any fresh create-react-app (version 3.3.0) project with pdfjs-dist installed. (link to original issue)

Steps to reproduce the problem

  1. Create new react app with create-react-app
  2. npm install pdfjs-dist
  3. Copy example
  4. npm start or npm run build

Input Code
Example repo

Expected behavior/code
npm start or npm run build succesfully without unreasonable memory usage

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
No additional configuration except of what CRA gives us

Environment

System:
    OS: Windows 10 10.0.18362
  Binaries:
    Node: 12.13.1 - C:\Program Files\nodejs\node.EXE
    npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
  • Babel version(s): v7.7.4
  • Node/npm version: Node 12/npm 6
  • OS: Windows 10 Enterprise 1903
@babel-bot
Copy link
Collaborator

Hey @artisb45! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@midgethoen
Copy link

I just realise I commented underneath the wrong issue.

I have patched the file described in the PR, but this doenst fix the memory error for me.

FYI, however, by deleting the sourcemaps from the pdfjs-dist package i can get CRA to run again.

@JLHwung JLHwung reopened this Dec 18, 2019
@JLHwung
Copy link
Contributor

JLHwung commented Dec 18, 2019

Update: The issue is not fixed since I misidentified the memory bottleneck.

For CRA users, you can remove the source maps from the pdfjs-dist package (thanks to @midgethoen).

Babel 7.6.4 works because inputSourceMap is not functioning, which is later fixed in #10623. However inputSourceMap bloats the memory via JSON.parse/JSON.stringify on this big source maps (3.13MB) in pdfjs-dist, just in order to merge this source map with the source map generated by babel transform.

@midgethoen
Copy link

Thnx for the quick response @JLHwung. Hopefully I can test the patch out later today.

@midgethoen
Copy link

Huzzah 🎉 it has been fixed for me. thnx again.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: perf Has PR i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: core
Projects
None yet
5 participants