mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
After PR 2317, which landed in 2012, we'd immediately clean-up after rendering for pages with large image resources. This had the effect that re-rendering, e.g. after zooming, would force us to re-parse the entire page which could easily lead to bad performance. In PR 16108, which landed in 2023, we tried to lessen the impact of that by slightly delaying clean-up however that's obviously not a perfect solution (and it increased the complexity of the relevant code). Furthermore, the condition for this "immediate" clean-up seems a bit arbitrary to me since a page could easily contain a large number of smaller images whose total size vastly exceeds the threshold. Hence this patch, which suggests that we remove the conditional and delayed clean-up after rendering. Compared to the situation back in 2012, a number of things have improved since: - We have *multiple* caches for repeated image-resources on the worker-thread[1], which helps reduce overall memory usage and improves performance. - We downsize huge images on the worker-thread, which means that the images we're using on the main-thread cannot be arbitrarily large. - The amount of available RAM on devices should be a lot higher, since more than a decade has passed. A future improvement here, for more resource constrained environments, could be to instead clean-up when actually needed using e.g. `WeakRef`s (see issue 18148). --- [1] More specifically: - `LocalImageCache`, which caches image-data by /Name and /Ref on the `PartialEvaluator.prototype.getOperatorList` level. - `RegionalImageCache`, which caches image-data by /Ref on the `PartialEvaluator`-instance (i.e. at the page) level. - `GlobalImageCache`, which caches image-data by /Ref globally at the document level. |
||
---|---|---|
.. | ||
core | ||
display | ||
images | ||
scripting_api | ||
shared | ||
interfaces.js | ||
license_header.js | ||
license_header_libre.js | ||
pdf.image_decoders.js | ||
pdf.js | ||
pdf.sandbox.external.js | ||
pdf.sandbox.js | ||
pdf.scripting.js | ||
pdf.worker.js |