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

Attempt to remove the special JpegStream.getBytes method and utilize the regular DecodeStream one instead #9260

Merged
merged 1 commit into from
Dec 10, 2017
Merged

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Dec 10, 2017

Note that no other image stream implements a special getBytes method, which makes JpegStream look somewhat odd.

I'm actually not sure what purpose this methods serves, since I successfully ran all tests locally with it commented out. Furthermore, I also ran tests with an added if (length && length !== this.bufferLength) { throw new Error('length mismatch'); } check, and didn't get a single test failure in that case either.

Looking at the history, it seems that this code originated back in PR #4528, but as far as I can tell there's no mention in either commit messages nor PR comments of why it was necessary to add a "special" getBytes function for the JpegStream.
My assumption is that there's a good reason why this method was added, e.g. to address a specific regression in one of the reference tests. However, I did check out commit 58f697f locally and ran tests with this method commented out, and there didn't seem to be any image-related failures in that case either!?

Hence I'm suggesting that we attempt to simplify this code slightly be removing this special getBytes method. However, please note that there's perhaps a small risk of regressions in an edge-case where we currently have insufficient test-coverage.

…e the regular `DecodeStream` one instead

Note that no other image stream implements a special `getBytes` method, which makes `JpegStream` look somewhat odd.

I'm actually not sure what purpose this methods serves, since I successfully ran all tests locally with it commented out. Furhermore, I also ran tests with an added `if (length && length !== this.bufferLength) { throw new Error('length mismatch'); }` check, and didn't get a single test failure in that case either.

Looking at the history, it seems that this code originated back in PR 4528, but as far as I can tell there's no mention in either commit messages nor PR comments of why it was necessary to add a "special" `getBytes` function for the `JpegStream`.
My assumption is that there's a good reason why this method was added, e.g. to address a *specific* regression in one of the reference tests. However, I did check out commit 58f697f locally and ran tests with this method commented out, and there didn't seem to be any image-related failures in that case either!?

Hence I'm suggesting that we attempt to simplify this code slightly be removing this special `getBytes` method. However, please note that there's perhaps a *small* risk of regressions in an edge-case where we currently have insufficient test-coverage.
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/86ba77e7ed37752/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/5713a0a90a42415/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/86ba77e7ed37752/output.txt

Total script time: 17.01 mins

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/5713a0a90a42415/output.txt

Total script time: 23.39 mins

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

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

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

I agree with your reasoning. Having code that does not make sense is in my opinion worse than finding a (very unlikely) regression later on, because then we at least have a test case for it. Thank you for the patch!

@timvandermeij timvandermeij merged commit 095c63c into mozilla:master Dec 10, 2017
@Snuffleupagus Snuffleupagus deleted the rm-JpegStream.getBytes branch December 11, 2017 08:49
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…ytes

Attempt to remove the special `JpegStream.getBytes` method and utilize the regular `DecodeStream` one instead
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