forked from mirrors/gecko-dev
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 |
||
|---|---|---|
| .. | ||
| build | ||
| web | ||
| PdfJs.jsm | ||
| PdfjsChild.jsm | ||
| PdfJsDefaultPreferences.jsm | ||
| PdfJsNetwork.jsm | ||
| PdfjsParent.jsm | ||
| PdfJsTelemetry.jsm | ||
| PdfSandbox.jsm | ||
| PdfStreamConverter.jsm | ||