Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AtiX
Copy link
Contributor

@AtiX AtiX commented Dec 11, 2025

This PR improves text rendering performance by skipping costly strokeColor.getPattern() and fillColor.getPattern() calculations when executing showText().

Background: we noticed very slow page render speed for some particular PDFs. After investigation, it turns out that if previously a stroke/fill pattern was set, the pattern is still being calculated independent of whether it's needed or not. This caused a high CPU/memory usage and thus a slow page render speed.

This is one "example culprit" (extract from the PDF):

/Artifact <</BBox[ 35.4331 209.917 290.551 228.917]/Type/Layout>>BDC
Q
19 w /Pattern CS %<-- pattern is set
/Pt0 SCN
/GS2 gs
q
1 0 0 1 35.433098 219.417267 cm
0 0 m
255.117996 0 l
S %<-- pattern is used for the stroke of the line
Q
EMC
/P <</MCID 1>>BDC
/GS3 gs
q
BT
/F2 1 Tf
-0.025 Tw 9 0 0 9 35.433098 784.440125 Tm
(somit)Tj %<-- text "somit" is being rendered, but no stroke rendering has been defined
ET
Q
q
BT

Here is the full pdf of the page - you can open it in Firefox to see how slow it loads:
weil-im-schoenbuch_2025_50_Seite12.pdf

@calixteman
Copy link
Contributor

Good catch ! Thank you for the patch.
Once you fix the 2 nits, I'll run the tests.

@AtiX
Copy link
Contributor Author

AtiX commented Dec 12, 2025

@calixteman thanks for the quick review, PR is updated!

@calixteman
Copy link
Contributor

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/542b1022030443f/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/6181da59a738123/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/542b1022030443f/output.txt

Total script time: 39.36 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.241.84.105:8877/542b1022030443f/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/6181da59a738123/output.txt

Total script time: 77.87 mins

  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.193.163.58:8877/6181da59a738123/reftest-analyzer.html#web=eq.log

@calixteman calixteman merged commit f824f38 into mozilla:master Dec 12, 2025
9 checks passed
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.

4 participants