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

slow initial rendering on latex doc with interesting fonts #4935

Closed
samth opened this issue Jun 13, 2014 · 5 comments
Closed

slow initial rendering on latex doc with interesting fonts #4935

samth opened this issue Jun 13, 2014 · 5 comments

Comments

@samth
Copy link

samth commented Jun 13, 2014

This document renders very slowly -- first a few characters appear, then it spins for a long time, and then everything else appears quickly.

This is with FF 32.0a1, PDF.js: 0.8.1334, Linux. No warnings on the console.

@timvandermeij
Copy link
Contributor

I can confirm this using Windows 7 x64, Firefox Nightly 30.0a1 (64-bit, HWA on) and the latest PDF.js development version. Memory consumption is also high.

@yurydelendik
Copy link
Contributor

Oh, wow! This PDF embeds about 500 fonts -- I guess one per letter :)

@samth
Copy link
Author

samth commented Jun 14, 2014

Remarkably, it loads quite fast in evince.

@yurydelendik
Copy link
Contributor

Right.... we are allocating too many cMaps and toUnicodes (even for Identity) -- in Chrome profiler size for those two ~2.6M and we have 420 of them.

@nnethercote
Copy link
Contributor

Pretty much all the activity is here, from builtToUnicode():

      for (var i = firstChar; i <= lastChar; i++) {
        toUnicode[i] = String.fromCharCode(i);
      }

This loop is executed 400+ times, and every single time firstChar is 0 and lastChar is 65535. So 400 identical identity toUnicode maps are built.

The best thing would be to avoid building the maps altogether, similar to #5135. This will probably require abstracting these tables into a class, doing all accesses via getter/setter methods, and then having a special sub-class for identity maps.

nnethercote added a commit to nnethercote/pdf.js that referenced this issue Aug 8, 2014
When loading the PDF from issue mozilla#4935, this change reduces peak RSS from
~2400 to ~300 MiB, and improves overall speed by ~81%, from 6336 ms to
1222 ms.
@nnethercote nnethercote mentioned this issue Aug 8, 2014
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

4 participants