Skip to content

[api-minor] Move Type3-glyph compilation to the worker-thread #19736

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

@Snuffleupagus Snuffleupagus commented Mar 29, 2025

After PR #19731 the format of compiled Type3-glyphs is now simple enough that the compilation can be moved to the worker-thread, without introducing any significant additional complexity.
This allows us to, ever so slightly, simplify the implementation in src/display/canvas.js since the Type3 operatorLists will now directly include standard path-rendering operators (using the format introduced in PR #19689).

As part of these changes we also stop caching Type3 image masks since: we've not come across any cases where that actually helps, they're usually fairly small, and it simplifies the code.

Note that one "negative" change introduced in this patch is that we'll now compile Type3-glyphs eagerly, whereas previously we'd only do that lazily upon their first use.
However, this doesn't seem to impact performance in any noticeable way since the compilation is fast enough (way below 1 ms/glyph in my testing) and Type3-fonts are also limited to just 256 glyphs. Also, many (or most?) Type3-fonts don't even use image masks and are thus not affected by these changes.

@Snuffleupagus Snuffleupagus force-pushed the compileType3Glyph-worker branch 6 times, most recently from 98a2a96 to 2dc260a Compare March 30, 2025 08:27
@Snuffleupagus Snuffleupagus force-pushed the compileType3Glyph-worker branch 5 times, most recently from 27881bd to a6d6e1c Compare March 30, 2025 10:15
@Snuffleupagus Snuffleupagus force-pushed the compileType3Glyph-worker branch 2 times, most recently from 6b4f184 to 42b0a12 Compare March 31, 2025 18:07
After PR 19731 the format of compiled Type3-glyphs is now simple enough that the compilation can be moved to the worker-thread, without introducing any significant additional complexity.
This allows us to, ever so slightly, simplify the implementation in `src/display/canvas.js` since the Type3 operatorLists will now directly include standard path-rendering operators (using the format introduced in PR 19689).

As part of these changes we also stop caching Type3 image masks since: we've not come across any cases where that actually helps, they're usually fairly small, and it simplifies the code.

Note that one "negative" change introduced in this patch is that we'll now compile Type3-glyphs *eagerly*, whereas previously we'd only do that lazily upon their first use.
However, this doesn't seem to impact performance in any noticeable way since the compilation is fast enough (way below 1 ms/glyph in my testing) and Type3-fonts are also limited to just 256 glyphs. Also, many (or most?) Type3-fonts don't even use image masks and are thus not affected by these changes.
@Snuffleupagus Snuffleupagus force-pushed the compileType3Glyph-worker branch from 42b0a12 to 9cd5a96 Compare April 1, 2025 07:09
@mozilla mozilla deleted a comment from moz-tools-bot Apr 1, 2025
@mozilla mozilla deleted a comment from moz-tools-bot Apr 1, 2025
@mozilla mozilla deleted a comment from moz-tools-bot Apr 1, 2025
@mozilla mozilla deleted a comment from moz-tools-bot Apr 1, 2025
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/f753ff3f10aff95/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/af5de4a1401c341/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/af5de4a1401c341/output.txt

Total script time: 30.28 mins

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

@Snuffleupagus Snuffleupagus marked this pull request as ready for review April 1, 2025 09:26
@Snuffleupagus Snuffleupagus requested a review from calixteman April 1, 2025 09:26
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/f753ff3f10aff95/output.txt

Total script time: 61.16 mins

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

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you.

@Snuffleupagus Snuffleupagus merged commit e5fbf52 into mozilla:master Apr 1, 2025
9 checks passed
@Snuffleupagus Snuffleupagus deleted the compileType3Glyph-worker branch April 1, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants