Closed Bug 962933 Opened 6 years ago Closed 6 years ago

pdf.js: be smarter about passing image data from the worker


(Firefox :: PDF Viewer, defect, P3)




Firefox 29


(Reporter: njn, Assigned: njn)


(Blocks 1 open bug)


Currently, we decode all images in a PDF into a 32-bit RGBA buffer in the worker, and then pass that to the main thread, which puts the data to a canvas (in slices, so the main thread doesn't need to use much memory).

There are some cases where this is outrageously inefficient. For example, scanned black and white documents are common. They have one bit per pixel, and so expanding to a 32-bit RGBA buffer is a 32x increase.

Therefore, for certain common, easy cases, we should allow image data to be passed in a form other than 32-bit RGBA. 1-bit black and white is the obvious first alternative.

This complicates things for the main thread display code, but it's worth it. I have a draft patch implementing this. For, if you scroll all the way to the bottom and wait for the last page to display...

- Currently, it takes about 200 seconds, and RSS peaks at 7,800 MiB.

- With my patch, it takes about 25 seconds, and RSS peaks at about 690 MiB.
Blocks: 949650
RyanVM, do we have a bug open for another pdf.js uplift before FF29's dev cycle closes?
Flags: needinfo?(ryanvm)
No, but feel free to file and assign to me if you want. Otherwise, I'll take care of it.
Flags: needinfo?(ryanvm)
Depends on: 965861
Fixed on trunk by bug 965861.
Assignee: nobody → n.nethercote
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 29
You need to log in before you can comment on or make changes to this bug.