fune/toolkit/components/pdfjs
Jonas Jenwald 7c50ea0cdb Bug 1757527 - Slightly reduce (repeated) message passing overhead when localizing the PDF Viewer. r=pdfjs-reviewers,calixte,bdahl
Currently there's a fair bit of unneeded overhead when localizing the PDF Viewer, since *every single* string requires a round-trip from the `viewer.js` file to the `PdfStreamConverter.jsm` file.
This despite the fact that the relevant `viewer.properties` file is read *only once*, and its result is then cached, see https://searchfox.org/mozilla-central/rev/8f42809e51cb07aa4f5739932a06d14581e9dd4a/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#470-473

Hence we can improve things here by instead sending the *entire* localization data at once when it's first requested, and also cache it in the viewer, to reduce completely unneeded message passing overhead caused by localizing the PDF Viewer.

To put these changes into perspective, let's look at what happens when loading the PDF Specification; i.e. https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
When loading that document we first of all need to localize the viewer UI, however the initialization/rendering of the PDF Document itself also causes some l10n-string lookups. All-in-all, simply loading the above PDF document in Firefox currently results in just over `3900` l10n-strings being fetched (with most of them being duplicates).
Furthermore, all these l10n-string lookups also have a measurable performance impact on the viewer UI localization. Using some, admittedly crude, benchmarking with `console.time/timeEnd` around the viewer UI localization code in https://searchfox.org/mozilla-central/rev/8f42809e51cb07aa4f5739932a06d14581e9dd4a/toolkit/components/pdfjs/content/web/viewer.js#484-485 gives the following results (using the best observed values, with `privacy.reduceTimerPrecision = false` set):

 - With the current code, the viewer UI localization takes around `12-13` ms.

 - With this patch, the viewer UI localization takes around `4-5` ms.

While these improvements are obviously not huge, they thus cannot hurt as far as I'm concerned.

(Assuming this is accepted, I'll obviously follow-up with the relevant `web/viewer.js` patch at GitHub. However, these changes must be synchronized in the both the viewer/integration code.)

Differential Revision: https://phabricator.services.mozilla.com/D139928
2022-03-11 01:24:05 +00:00
..
content Bug 1757527 - Slightly reduce (repeated) message passing overhead when localizing the PDF Viewer. r=pdfjs-reviewers,calixte,bdahl 2022-03-11 01:24:05 +00:00
test Bug 1743838 - Update pdf.js to version 2.12.248 r=pdfjs-reviewers,calixte 2021-12-02 23:04:11 +00:00
chrome.manifest
components.conf
jar.mn
LICENSE
moz.build
moz.yaml Bug 1757825 - Update pdf.js to version 2.14.13 r=pdfjs-reviewers,marco 2022-03-02 22:41:56 +00:00
pdfjs.js
README.mozilla Bug 1757825 - Update pdf.js to version 2.14.13 r=pdfjs-reviewers,marco 2022-03-02 22:41:56 +00:00

This is the PDF.js project output, https://github.com/mozilla/pdf.js

Current extension version is: 2.14.13

Taken from upstream commit: 234aa9a50