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

Serialize errors before invoking postMessage #6332

Merged
merged 1 commit into from
Aug 19, 2015

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Aug 8, 2015

Sometimes (when an error occurs), PDF.js gets stuck. The viewer is then indefinitely waiting for a promise to resolve, which never happens because of the DataCloneError. This PR addresses the issue by converting the error to a string before throwing.

Firefox: "DataCloneError: The object could not be cloned."
Chrome: "DataCloneError: Failed to execute 'postMessage' on 'WorkerGlobalScope': An object could not be cloned."

Here's an isolated test case, if you want to see what happens when an Error object is passed to postMessage:

try {
    window.postMessage(new Error(), '*')
} catch (e) {
    alert(e);
}

Serialize errors to make sure that the callback is still invoked when
an error is thrown.

Firefox:
"DataCloneError: The object could not be cloned."

Chrome:
"DataCloneError: Failed to execute 'postMessage' on 'WorkerGlobalScope': An object could not be cloned."
@Rob--W Rob--W added the core label Aug 8, 2015
@Hengjie
Copy link
Contributor

Hengjie commented Aug 10, 2015

I've noticed this issue as well, it's great to hear there's a fix for it!

@Snuffleupagus
Copy link
Collaborator

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/393d6ae51d091d9/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/7a3d8aafe6e2564/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/7a3d8aafe6e2564/output.txt

Total script time: 19.20 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/393d6ae51d091d9/output.txt

Total script time: 19.61 mins

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

@Rob--W
Copy link
Member Author

Rob--W commented Aug 14, 2015

@timvandermeij On IRC you asked for a PDF that triggers the error. Take any of the examples from https://encrypted.google.com/search?q=%22DataCloneError%3A%22+pdf.js, e.g. the PDF from https://bugzilla.mozilla.org/show_bug.cgi?id=911761 (https://bug911761.bmoattachments.org/attachment.cgi?id=798520).

(in PDF.js: 1.1.132)

Snuffleupagus added a commit that referenced this pull request Aug 19, 2015
Serialize errors before invoking postMessage
@Snuffleupagus Snuffleupagus merged commit ede5235 into mozilla:master Aug 19, 2015
@Snuffleupagus
Copy link
Collaborator

Looks good, thanks for the patch!

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.

4 participants