Skip to content

[api-minor] Add a |cancel| method to PDFDocumentLoadingTask#5629

Closed
Snuffleupagus wants to merge 1 commit intomozilla:masterfrom
Snuffleupagus:cancel-getDocument
Closed

[api-minor] Add a |cancel| method to PDFDocumentLoadingTask#5629
Snuffleupagus wants to merge 1 commit intomozilla:masterfrom
Snuffleupagus:cancel-getDocument

Conversation

@Snuffleupagus
Copy link
Collaborator

(Replaces PR #5234.)

Fixes #3485.
Fixes #4774.
Fixes #5228.
Fixes #5572.

@brendandahl brendandahl added this to the 2015 Q1 milestone Jan 8, 2015
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2015

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/93203fc5f3b68f7/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2015

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/708c990f1c84eef/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2015

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/708c990f1c84eef/output.txt

Total script time: 17.43 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2015

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/93203fc5f3b68f7/output.txt

Total script time: 23.09 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Jan 9, 2015

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/222a03cb5ec4912/output.txt

web/viewer.js Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to show any errors to user -- first, it was his decision in first place and, second, it may confuse the user if he chooses to load a different document and he received an error instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; which is why the code below just prints a message in the console, and then returns immediately thus avoiding triggering error.
Hence the only thing the user could potentially see, is a message logged in the console.
Are you saying that we shouldn't even print anything in the console, and just return straight away instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say not even a console message, but let's print info message just for troubleshooting.

@yurydelendik
Copy link
Contributor

It's more complex than I thought. We need to cancel it not only on the api.js side, but on the worker.js side as well. Which means any in-progress xhr must be terminated, any rendering operations terminated. Also, we probably need to add a callback similar to onProgress, on signify end of document loading (onComplete?) -- it might not fire on disableAutoFetch, but it will signify end of cancel method "effectiveness". We might even need to rethink whole PDFDocumentLoadingTask thing.

@yurydelendik
Copy link
Contributor

in-progress xhr must be terminated, any rendering operations terminated.

Maybe just terminate xhr and will not allow any I/O operations after that. PDFDocumentProxy.destroy shall worry about worker cleanup and aborting operations.

@Snuffleupagus
Copy link
Collaborator Author

Maybe just terminate xhr and will not allow any I/O operations after that.

Isn't the patch already doing this, at least partially? See https://github.com/mozilla/pdf.js/pull/5629/files#diff-0ecad279ed2252e3eb47a4d96ec1463cR270 (which might need a slightly better comment).

Since api.js#L951 calls worker.js#L459, which in turns calls pdf_manager.js#L218 and then finally network.js#L262. As far as I can tell, this should be sufficient to close any open connections.
I've, so far, only tested this in the GENERIC viewer, where it appears to work as it should.
Is my understand of the code correct, or does the existing code not close everything you had in mind?

@yurydelendik
Copy link
Contributor

Yes. But we don't have exposed api for it at getDocument level. Also this api call shall not destroy the worker if getDocument is successfully resolved - we have destroy in PDFDocumentProxy. So this PR will be about refactoring mess with states we have atm

@Snuffleupagus Snuffleupagus changed the title Add a |cancel| method to PDFDocumentLoadingTask [api-minor] Add a |cancel| method to PDFDocumentLoadingTask Mar 25, 2015
@timvandermeij timvandermeij removed this from the 2015 Q1 milestone Apr 29, 2015
@yurydelendik yurydelendik self-assigned this Aug 3, 2015
@Snuffleupagus Snuffleupagus deleted the cancel-getDocument branch October 21, 2015 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

5 participants