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

Fix how we detect and handle missing glyph data. #8580

Merged
merged 1 commit into from
Jul 4, 2017

Conversation

brendandahl
Copy link
Contributor

@brendandahl brendandahl commented Jun 28, 2017

I had started looking at #8255 awhile back, but after seeing @Snuffleupagus pr #8572 I realized what was going on.

This fixes a couple of things:

  • If dupFirstEntry was used in sanitizeGlyphLocations then the glyph count was too high and we ended up reading beyond loca table and disabling glyph that could actually be there.
  • We didn't always mark missinglyphs as missing, now we always check the glyph length.
  • We tried to adjust the mapping of missing glyphs. Often there are thousand of missing glyphs in regions that would be re-mapped which caused us to run out of private use locations.

Fixes #8255.
Fixes #8570.
Fixes #7696.

@brendandahl
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/b3573d0a7ceda07/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/9bad1d590e6e492/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/9bad1d590e6e492/output.txt

Total script time: 29.51 mins

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

Image differences available at: http://54.215.176.217:8877/9bad1d590e6e492/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/b3573d0a7ceda07/output.txt

Total script time: 60.00 mins

@brendandahl
Copy link
Contributor Author

/botio-linux test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/0ed859f6e25b17d/output.txt

@brendandahl
Copy link
Contributor Author

I didn't see any failure locally (on macOS), but it looks like things have changed (for the worse) on windows. I'm guessing more glyphs are in the private use area not using the CJK shaper, but I'll have to look into it.

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/0ed859f6e25b17d/output.txt

Total script time: 16.54 mins

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

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

@Snuffleupagus
Copy link
Collaborator

I didn't see any failure locally (on macOS), but it looks like things have changed (for the worse) on windows. I'm guessing more glyphs are in the private use area not using the CJK shaper, but I'll have to look into it.

One additional data-point, in case it's helpful: I ran the full test-suite locally on Windows 7 (in Firefox Nightly 56), and I didn't notice any failures locally either.
However, I've got HWA (hardware acceleration) enabled locally, and I'm assuming that the bot runs with HWA disabled, which may help explain/pinpoint the issue!?

@@ -834,6 +834,7 @@ var Font = (function FontClosure() {
if ((usedFontCharCodes[fontCharCode] !== undefined ||
isProblematicUnicodeLocation(fontCharCode) ||
(isSymbolic && !hasUnicodeValue)) &&
!missingGlyphs[glyphId] &&
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Jun 28, 2017

Choose a reason for hiding this comment

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

Just asking, and it might be a totally pointless micro-optimization, but would it make sense (at all) to check !missingGlyphs[glyphId] first in this condition? I.e. instead do:

if (!missingGlyphs[glyphId] &&
    (usedFontCharCodes[fontCharCode] !== undefined ||
     isProblematicUnicodeLocation(fontCharCode) ||
     (isSymbolic && !hasUnicodeValue)) &&
    nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left.

The reason that I'm asking is that we could then avoid pointless isProblematicUnicodeLocation function calls when we know that a glyph is missing, since I'm assuming that it's cheaper to lookup missingGlyphs[glyphId] than it's to call a function?

Again, this might be a completely unnecessary change, but I figured it can't hurt to ask!
Edit: If nothing else, it will help improve my understanding of these things :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it depends on a number of things and would really need to be benchmarked, but I don't thing this code is particularly hot, so it's not really worth worrying about it. I've updated it to be first though.

@brendandahl
Copy link
Contributor Author

Looks like the windows failures may be a firefox update since the refs failed over in #8585 (comment)

@brendandahl
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2017

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/6d0b994bd5d9a33/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2017

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/f18d8ce6030aa74/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2017

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/6d0b994bd5d9a33/output.txt

Total script time: 16.52 mins

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

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

@pdfjsbot
Copy link

pdfjsbot commented Jul 3, 2017

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/f18d8ce6030aa74/output.txt

Total script time: 29.18 mins

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

Image differences available at: http://54.215.176.217:8877/f18d8ce6030aa74/reftest-analyzer.html#web=eq.log

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

This is a really nice improvement, not to mention simplification, of the way we detect missing glyphs.
This makes a lot more sense than the old hacks (that I added); thanks for doing this!

@Snuffleupagus
Copy link
Collaborator

/botio makeref

@pdfjsbot
Copy link

pdfjsbot commented Jul 4, 2017

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/fe3d0ee9524daaa/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 4, 2017

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/bcbdfcc542acc37/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Jul 4, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/bcbdfcc542acc37/output.txt

Total script time: 15.64 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

pdfjsbot commented Jul 4, 2017

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/fe3d0ee9524daaa/output.txt

Total script time: 27.11 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Fix how we detect and handle missing glyph data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants