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 searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808) #5383

Merged
merged 1 commit into from
Dec 18, 2014
Merged

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Oct 4, 2014

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/a716f99d5968d46/output.txt

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Oct 4, 2014

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/2dd802736ea69ac/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Oct 4, 2014

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/4bc0931aadc8d7e/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Oct 4, 2014

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/2dd802736ea69ac/output.txt

Total script time: 2.90 mins

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

Image differences available at: http://107.22.172.223:8877/2dd802736ea69ac/reftest-analyzer.html#web=eq.log

@Snuffleupagus Snuffleupagus changed the title Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1070788) Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808) Oct 4, 2014
@pdfjsbot
Copy link

pdfjsbot commented Oct 4, 2014

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/4bc0931aadc8d7e/output.txt

Total script time: 22.94 mins

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

if (isName(filter)) {
filterNames = [filter.name];
} else if (isArray(filter)) {
for (i = 0, ii = filter.length; i < ii; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure how long that list typically is. but i think that you could move this code to a separate function which directly checks every element and does a quick return if one is found. This should be shorter in code and execution time.

something like this:
https://gist.github.com/CodingFabian/0731224202f8447cb805

@yurydelendik
Copy link
Contributor

Hmm, we had that at one point Snuffleupagus@c68dbd7#diff-6947033678b93d106e25614dd972e66fL123 . We need to verify why we need to revert that decision.

@yurydelendik
Copy link
Contributor

#1246

@yurydelendik
Copy link
Contributor

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://107.22.172.223:8877/e8072358c6db18e/output.txt

@yurydelendik
Copy link
Contributor

I verified. It regresses the ADP stuff. Can you add at the last "if" check condition to do that only for ASCII85.

@Snuffleupagus
Copy link
Collaborator Author

After thinking some more about this, I believe that it may not be such a great idea to rely only on the existence of white-space before the EI to decide that we've found the end of an ASCII85Decode stream. Hence I've basically reverted the patch to its first version, which checks that the EOD (end-of-data) marker has been found when we think that we have encountered the EI.

@yurydelendik
Copy link
Contributor

That's fine as well. Can you extract/refactor searching into two separate functions: for non-ASCII85 (which will just scan for '~') and regular search? In the future we can improve searching so other filter types, e.g. for HEX we can jump by 2*length first or walk-by-tags for JPX/JBIG/JPEG.

P.S. no need creating getFirstFilterName closure-function.

@yurydelendik
Copy link
Contributor

I wonder if we can add e.g. skipToEnd() for some streams (if that exists, rely on it)

@Snuffleupagus
Copy link
Collaborator Author

@yurydelendik I've attempted to refactor this along the lines you suggested above. Please let me know if this is going in the right direction!

@yurydelendik
Copy link
Contributor

Yes, that looks good. One thing: I looks like after default search your stream stop after 'EI', but for AHx and A85 before. Will that be a problem?

@Snuffleupagus
Copy link
Collaborator Author

I looks like after default search your stream stop after 'EI', but for AHx and A85 before. Will that be a problem?

I thought about that, but since the tests passed it seemed fine. It's really good that you asked though, because I found that it does break things. One indication that something went wrong was that text selection stopped working.
I've added a helper function to advance the stream to after the EI, and I verified that the final stream position is now the same as before.

@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/12f3a8ad7e6ea18/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/ce386f97d099350/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://107.22.172.223:8877/12f3a8ad7e6ea18/output.txt

Total script time: 3.02 mins

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

Image differences available at: http://107.22.172.223:8877/12f3a8ad7e6ea18/reftest-analyzer.html#web=eq.log

@yurydelendik
Copy link
Contributor

/botio-windows test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/7ae97467b69cff2/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/ce386f97d099350/output.txt

Total script time: 24.11 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/7ae97467b69cff2/output.txt

Total script time: 20.67 mins

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

@yurydelendik
Copy link
Contributor

@Snuffleupagus, looks good, can you squash commits?

@Snuffleupagus
Copy link
Collaborator Author

can you squash commits?

Done.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2014

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/07879f16db8599f/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2014

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/f9f6d80a0ab59ee/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2014

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/07879f16db8599f/output.txt

Total script time: 16.83 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Dec 9, 2014

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/f9f6d80a0ab59ee/output.txt

Total script time: 22.73 mins

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

var FF = 0xFF, D9 = 0xD9;
var startPos = stream.pos, ch, length;
while ((ch = stream.getByte()) !== -1) {
if (ch === FF && stream.peekByte() === D9) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking out loud: I don't remember if you need to ignore (0xFF 0xFF)*2 0xF9 sequences

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed this part of the patch, since I'd rather get the main part landed now in order to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1077808 (given that the PR has been open for over two months).
Once this PR is merged, I can submit a followup which changes the inline JPEG image case.

…s (bug 1077808)

This patch changes searching for the end of inline image streams to rely on the EOD marker for the filters: ASCII85Decode and ASCIIHexDecode.
@Snuffleupagus
Copy link
Collaborator Author

/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/23f11e1868ea98f/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/aa49c65b9e8845f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/23f11e1868ea98f/output.txt

Total script time: 17.20 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/aa49c65b9e8845f/output.txt

Total script time: 22.48 mins

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

@yurydelendik
Copy link
Contributor

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @yurydelendik received. Current queue size: 1

Live output at: http://107.22.172.223:8877/0bf6c17cb2af150/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_makeref from @yurydelendik received. Current queue size: 1

Live output at: http://107.21.233.14:8877/a55ffed65370b00/output.txt

@yurydelendik
Copy link
Contributor

Thank you for the patch

yurydelendik added a commit that referenced this pull request Dec 18, 2014
Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808)
@yurydelendik yurydelendik merged commit f4fa7aa into mozilla:master Dec 18, 2014
@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/0bf6c17cb2af150/output.txt

Total script time: 17.22 mins

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

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/a55ffed65370b00/output.txt

Total script time: 22.70 mins

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

@Snuffleupagus Snuffleupagus deleted the bug-1077808 branch December 18, 2014 16:44
speedplane pushed a commit to speedplane/pdf.js that referenced this pull request Feb 24, 2015
Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808)
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