Skip to content
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

Merged
merged 1 commit into from
Feb 8, 2020

Conversation

Snuffleupagus
Copy link
Collaborator

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.

@Snuffleupagus Snuffleupagus force-pushed the api-cleanup-returns branch 2 times, most recently from e982d8d to 349d0f9 Compare February 7, 2020 15:55
@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2020

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/e80be8d1160bd54/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2020

From: Bot.io (Windows)


Received

Command 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.
@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/e80be8d1160bd54/output.txt

Total script time: 2.73 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Feb 7, 2020

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/2ac32d741ddc57a/output.txt

Total script time: 4.81 mins

  • Unit Tests: Passed

@timvandermeij timvandermeij merged commit 7948faf into mozilla:master Feb 8, 2020
@timvandermeij
Copy link
Contributor

This looks like a useful API addition. Thanks!

@Snuffleupagus Snuffleupagus deleted the api-cleanup-returns branch February 9, 2020 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants