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

8258986: getColor throws IOOBE when PixelReader reads the same pixel twice #389

Closed

Conversation

@kevinrushforth
Copy link
Member

@kevinrushforth kevinrushforth commented Jan 29, 2021

As indicated in the JBS bug, using a PixelReader to read a scaled image in HiDPI mode, for example an @2x image, to read more than one pixel will read data from the wrong location in the image, usually leading to an IOOBE.

The bug is in the getPixelAccessor method of Prism Image. The method correctly creates a new Accessor if one hasn't already been created, but then it unconditionally wraps the current Accessor in a ScaledPixelAccessor if the scale is > 1. So the second time this method is called, it created another ScaledPixelAccessor that wraps the first ScaledPixelAccessor, meaning that the indexes into the pixel array are multiplied by 4. This continues for each new call to this method.

The fix is to only wrap an Accessor in a ScaledPixelAccessor the first time, when it is created.

I added a test, which is run for both scaled and unscaled images, to ensure that we get the right value when reading a pixel, and that reading it a second time returns the same result. Without the fix, the new test will fail with IOOBE when the scale factor is two. Related to this, I initially commented out the wrapping in a ScaledPixelAccessor entirely, just to see what would happen, and none of the existing tests caught it. The new test will catch this.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8258986: getColor throws IOOBE when PixelReader reads the same pixel twice

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jfx pull/389/head:pull/389
$ git checkout pull/389

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 29, 2021

👋 Welcome back kcr! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Jan 29, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 29, 2021

Webrevs

@kevinrushforth kevinrushforth requested a review from arapte Feb 2, 2021
@arapte
arapte approved these changes Feb 9, 2021
Copy link
Member

@arapte arapte left a comment

+1 Test and sanity check looks good.

@openjdk
Copy link

@openjdk openjdk bot commented Feb 9, 2021

@kevinrushforth This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8258986: getColor throws IOOBE when PixelReader reads the same pixel twice

Reviewed-by: arapte

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 10 new commits pushed to the master branch:

  • 676cf3e: 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak
  • d4058a1: 8260475: Deprecate for removal protected access members in DateTimeStringConverter
  • 887a443: Merge
  • 0f20a98: 8252389: Fix mistakes in FX API docs
  • 425c335: 8254836: Cherry pick GTK WebKit 2.30.3 changes
  • 215384d: 8260246: Ensemble: Update version of Lucene to 7.7.3
  • e481f8c: 8260163: IrresponsiveScriptTest.testInfiniteLoopInScript unit test fails on Windows
  • 217a8cb: 8259680: Need API to query states of CAPS LOCK and NUM LOCK keys
  • db6941d: 8256283: IndexOutOfBoundsException when sorting a TreeTableView
  • b0a404d: 8259635: Update to 610.2 version of WebKit

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Feb 9, 2021
@kevinrushforth
Copy link
Member Author

@kevinrushforth kevinrushforth commented Feb 9, 2021

/integrate

@openjdk openjdk bot closed this Feb 9, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Feb 9, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 9, 2021

@kevinrushforth Since your change was applied there have been 10 commits pushed to the master branch:

  • 676cf3e: 8259046: ViewPainter.ROOT_PATHS holds reference to Scene causing memory leak
  • d4058a1: 8260475: Deprecate for removal protected access members in DateTimeStringConverter
  • 887a443: Merge
  • 0f20a98: 8252389: Fix mistakes in FX API docs
  • 425c335: 8254836: Cherry pick GTK WebKit 2.30.3 changes
  • 215384d: 8260246: Ensemble: Update version of Lucene to 7.7.3
  • e481f8c: 8260163: IrresponsiveScriptTest.testInfiniteLoopInScript unit test fails on Windows
  • 217a8cb: 8259680: Need API to query states of CAPS LOCK and NUM LOCK keys
  • db6941d: 8256283: IndexOutOfBoundsException when sorting a TreeTableView
  • b0a404d: 8259635: Update to 610.2 version of WebKit

Your commit was automatically rebased without conflicts.

Pushed as commit e85ce5a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kevinrushforth kevinrushforth deleted the kevinrushforth:8258986-getColor-OOBE branch Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants