-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Actually transfer eligible ImageMask data, rather than always copying it #10647
Conversation
By transfering `ArrayBuffer`s you can avoid having two copies of the same data, i.e. one copy on each of the worker/main-thread, for data that's used only *once* on the worker-thread. Note how the code in [`PDFImage.createMask`](https://github.com/mozilla/pdf.js/blob/80135378cadd98b55a835446f0857e4bc30524e0/src/core/image.js#L284-L285) goes to great lengths to actually enable tranfering of the image data. However in [`PartialEvaluator.buildPaintImageXObject`](https://github.com/mozilla/pdf.js/blob/80135378cadd98b55a835446f0857e4bc30524e0/src/core/evaluator.js#L336) the `cached` property is always set to `true`, which disqualifies the image data from being transfered; see [`getTransfers`](https://github.com/mozilla/pdf.js/blob/80135378cadd98b55a835446f0857e4bc30524e0/src/core/operator_list.js#L552-L554). For most ImageMask data this patch won't matter, since images found in the `/Resources -> /XObject` dictionary will always be indexed by name. However for *inline* images which contains ImageMask data, where only "small" images are cached (in both `parser.js` and `evaluator.js`), the current code will result in some unnecessary memory usage.
…method on the `OperatorList` This function is currently called with the `OperatorList` instance as its argument, hence I cannot think of any good reason for not just moving it into the `OperatorList` properly. (This will also help with other planned changes regarding the `ImageCache` functionality.)
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/347b500d0b7bd5c/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/da4a80e389dfd7b/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/347b500d0b7bd5c/output.txt Total script time: 18.12 mins
Image differences available at: http://54.67.70.0:8877/347b500d0b7bd5c/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/da4a80e389dfd7b/output.txt Total script time: 25.91 mins
Image differences available at: http://54.215.176.217:8877/da4a80e389dfd7b/reftest-analyzer.html#web=eq.log |
Looks good; thank you! |
By transfering
ArrayBuffer
s you can avoid having two copies of the same data, i.e. one copy on each of the worker/main-thread, for data that's used only once on the worker-thread.Note how the code in
PDFImage.createMask
goes to great lengths to actually enable tranfering of the image data. However inPartialEvaluator.buildPaintImageXObject
thecached
property is always set totrue
, which disqualifies the image data from being transfered; seegetTransfers
.For most ImageMask data this patch won't matter, since images found in the
/Resources -> /XObject
dictionary will always be indexed by name. However for inline images which contains ImageMask data, where only "small" images are cached (in bothparser.js
andevaluator.js
), the current code will result in some unnecessary memory usage.