-
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
[api-minor] Change PDFDocumentProxy.cleanup
/PDFPageProxy.cleanup
to return data
#11573
[api-minor] Change PDFDocumentProxy.cleanup
/PDFPageProxy.cleanup
to return data
#11573
Conversation
e982d8d
to
349d0f9
Compare
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/e80be8d1160bd54/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/2ac32d741ddc57a/output.txt |
…to return data This patch makes the following changes, to improve these API methods: - Let `PDFPageProxy.cleanup` return a boolean indicating if clean-up actually happened, since ongoing rendering will block clean-up. Besides being used in other parts of this patch, it seems that an API user may also be interested in the return value given that clean-up isn't *guaranteed* to happen. - Let `PDFDocumentProxy.cleanup` return the promise indicating when clean-up is finished. - Improve the JSDoc comment for `PDFDocumentProxy.cleanup` to mention that clean-up is triggered on *both* threads (without going into unnecessary specifics regarding what *exactly* said data actually is). Add a note in the JSDoc comment about not calling this method when rendering is ongoing. - Change `WorkerTransport.startCleanup` to throw an `Error` if it's called when rendering is ongoing, to prevent rendering from breaking. Please note that this won't stop *worker-thread* clean-up from happening (since there's no general "something is rendering"-flag), however I'm not sure if that's really a problem; but please don't quote me on that :-) All of the caches that's being cleared in `Catalog.cleanup`, on the worker-thread, *should* be re-filled automatically even if cleared *during* parsing/rendering, and the only thing that probably happens is that e.g. font data would have to be re-parsed. On the main-thread, on the other hand, clearing the caches is more-or-less guaranteed to cause rendering errors, since the rendering code in `src/display/canvas.js` isn't able to re-request any image/font data that's suddenly being pulled out from under it. - Last, but not least, add a couple of basic unit-tests for the clean-up functionality.
349d0f9
to
7117ee0
Compare
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/e80be8d1160bd54/output.txt Total script time: 2.73 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/2ac32d741ddc57a/output.txt Total script time: 4.81 mins
|
This looks like a useful API addition. Thanks! |
This patch makes the following changes, to improve these API methods:
Let
PDFPageProxy.cleanup
return a boolean indicating if clean-up actually happened, since ongoing rendering will block clean-up.Besides being used in other parts of this patch, it seems that an API user may also be interested in the return value given that clean-up isn't guaranteed to happen.
Let
PDFDocumentProxy.cleanup
return the promise indicating when clean-up is finished.Improve the JSDoc comment for
PDFDocumentProxy.cleanup
to mention that clean-up is triggered on both threads (without going into unnecessary specifics regarding what exactly said data actually is).Add a note in the JSDoc comment about not calling this method when rendering is ongoing.
Change
WorkerTransport.startCleanup
to throw anError
if it's called when rendering is ongoing, to prevent rendering from breaking.Please note that this won't stop worker-thread clean-up from happening (since there's no general "something is rendering"-flag), however I'm not sure if that's really a problem; but please don't quote me on that :-)
All of the caches that's being cleared in
Catalog.cleanup
, on the worker-thread, should be re-filled automatically even if cleared during parsing/rendering, and the only thing that probably happens is that e.g. font data would have to be re-parsed.On the main-thread, on the other hand, clearing the caches is more-or-less guaranteed to cause rendering errors, since the rendering code in
src/display/canvas.js
isn't able to re-request any image/font data that's suddenly being pulled out from under it.Last, but not least, add a couple of basic unit-tests for the clean-up functionality.