Skip to content

Send the AnnotationStorage-data to the worker-thread as a Map #13001

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

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

Rather than converting the AnnotationStorage-data to an Object, before sending it to the worker-thread, we should be able to simply send the internal Map directly.
The "structured clone algorithm" doesn't have a problem with Maps, however the LoopbackPort used when workers are disabled (e.g. in Node.js environments) didn't use to support them. With PR #12997 having lifted that restriction, we should now be able to simply send the AnnotationStorage-data as-is rather than having to iterate through it to first create an Object.

Please note: The changes in src/core/annotation.js could have been a lot more compact if we were able to use optional chaining in the src/core folder. Unfortunately that's still not possible, since SystemJS is being used in the development viewer (i.g. gulp server) and fixing that is still blocked by bug 1247687.

Rather than converting the `AnnotationStorage`-data to an Object, before sending it to the worker-thread, we should be able to simply send the internal `Map` directly.
The "structured clone algorithm" doesn't have a problem with `Map`s, however the `LoopbackPort` used when workers are *disabled* (e.g. in Node.js environments) didn't use to support them. With PR 12997 having lifted that restriction, we should now be able to simply send the `AnnotationStorage`-data as-is rather than having to iterate through it to first create an Object.

*Please note:* The changes in `src/core/annotation.js` could have been a lot more compact if we were able to use optional chaining in the `src/core` folder. Unfortunately that's still not possible, since SystemJS is being used in the development viewer (i.g. `gulp server`) and fixing that is *still* blocked by [bug 1247687](https://bugzilla.mozilla.org/show_bug.cgi?id=1247687).
@Snuffleupagus Snuffleupagus changed the title Send the AnnotationStorage-data to the worker-tread as a Map Send the AnnotationStorage-data to the worker-thread as a Map Feb 18, 2021
@Snuffleupagus Snuffleupagus force-pushed the AnnotationStorage-serializable branch from 181bda3 to e9038cc Compare February 18, 2021 16:13
@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/32ce877f8172b16/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/92d74328e298a83/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/32ce877f8172b16/output.txt

Total script time: 23.83 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/32ce877f8172b16/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/92d74328e298a83/output.txt

Total script time: 29.43 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED

Image differences available at: http://3.101.106.178:8877/92d74328e298a83/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit 3d80c21 into mozilla:master Feb 18, 2021
@timvandermeij
Copy link
Contributor

Nice work; thanks!

@Snuffleupagus Snuffleupagus deleted the AnnotationStorage-serializable branch February 18, 2021 23:29
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