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

8262085: Hovering Metal HTML Tooltips in different windows cause IllegalArgExc on Linux #2761

Closed
wants to merge 4 commits into from

Conversation

@azvegint
Copy link
Member

@azvegint azvegint commented Feb 27, 2021

This issue occurs only under MetalLookAndFeel on Linux.

It was introduced by JDK-8040630 fix.

component.setBounds(ownerX, ownerY, 1, 1);

This line adds an extra reshape call with 1x1 size right before getting another one with correct sizes.

If MetalToolTipUI#paint() call happens before getting correct sizes, it calculates paintTextR with negative sizes for component with 1x1 size, thus IAE is thrown.

The fix is to do not proceed with paint() for negative sizes.
The provided test fails for me in 0-30s interval(before the fix), other testing(client-tier1,2,3) looks good.


Progress

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

Issue

  • JDK-8262085: Hovering Metal HTML Tooltips in different windows cause IllegalArgExc on Linux

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2761/head:pull/2761
$ git checkout pull/2761

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 27, 2021

👋 Welcome back azvegint! 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.

Loading

@openjdk openjdk bot added the rfr label Feb 27, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 27, 2021

@azvegint The following label will be automatically applied to this pull request:

  • swing

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

Loading

@openjdk openjdk bot added the swing label Feb 27, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 27, 2021

Webrevs

Loading

public static void main(String[] args) throws Exception {
SwingUtilities.invokeLater(() -> {
try {
UIManager.setLookAndFeel(new MetalLookAndFeel());
Copy link
Member

@mrserb mrserb Feb 27, 2021

Choose a reason for hiding this comment

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

Can the test checks all installed L&F just to check for similar bugs?

Loading

Copy link
Member Author

@azvegint azvegint Feb 28, 2021

Choose a reason for hiding this comment

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

Sure.

Any idea why Linux is affected only?

Actually it is not. It is just can be easily reproduced during normal use on Linux only.
After test simplification it fails on every platform before the fix.

Loading

@mrserb
Copy link
Member

@mrserb mrserb commented Feb 27, 2021

Any idea why Linux is affected only?

Loading

@mrserb
Copy link
Member

@mrserb mrserb commented Feb 27, 2021

BTW the test can be simplified to something like this, failed at jdk8 as well.

        UIManager.setLookAndFeel(new MetalLookAndFeel());
        JToolTip tp = new JToolTip();
        tp.setTipText("<html><h1>Hello world</h1></html>");
        tp.setMinimumSize(new Dimension(1, 1));
        tp.setMaximumSize(new Dimension(1, 1));
        tp.setPreferredSize(new Dimension(1, 1));
        tp.setBounds(100, 100, 1, 1);
        BufferedImage img = new BufferedImage(100, 100, TYPE_INT_ARGB);
        Graphics2D g2d = img.createGraphics();
        tp.paint(g2d);
        g2d.dispose();

Loading

mrserb
mrserb approved these changes Feb 28, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 28, 2021

@azvegint 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:

8262085: Hovering Metal HTML Tooltips in different windows cause IllegalArgExc on Linux

Reviewed-by: serb, psadhukhan

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 4 new commits pushed to the master branch:

  • 702ca62: 8262185: G1: Prune collection set candidates early
  • 8bc8542: 8262195: Harden tests that use the HostsFileNameService (jdk.net.hosts.file property)
  • 20c93b3: 8261914: IfNode::fold_compares_helper faces non-canonicalized bool when running JRuby JSON workload
  • ddd550a: 8261308: C2: assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed

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.

Loading

@openjdk openjdk bot added the ready label Feb 28, 2021

if (paintTextR.width <= 0 || paintTextR.height <= 0) {
return;
}
Copy link
Contributor

@prsadhuk prsadhuk Mar 1, 2021

Choose a reason for hiding this comment

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

Any idea why only MetalToolTip is affected only? JDK-8040630 fix was generic so shouldn't we apply this fix in BasicToolTipUI#paint instead?

Loading

Copy link
Member Author

@azvegint azvegint Mar 1, 2021

Choose a reason for hiding this comment

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

Only Metal LaF uses BasicHTML#getHTMLBaseline for HTML tooltips painting.

Changing of BasicToolTipUI#paint will have no effect since it is not on the call stack.

Loading

@azvegint
Copy link
Member Author

@azvegint azvegint commented Mar 1, 2021

/integrate

Loading

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

@openjdk openjdk bot commented Mar 1, 2021

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

  • 75bf106: 8262028: Make InstanceKlass::implementor return InstanceKlass
  • fe8e370: 8262188: Add test to verify trace page sizes logging on Linux
  • 0a7fff4: 8261636: The test mapping in hugetlbfs_sanity_check should consider LargePageSizeInBytes
  • 702ca62: 8262185: G1: Prune collection set candidates early
  • 8bc8542: 8262195: Harden tests that use the HostsFileNameService (jdk.net.hosts.file property)
  • 20c93b3: 8261914: IfNode::fold_compares_helper faces non-canonicalized bool when running JRuby JSON workload
  • ddd550a: 8261308: C2: assert(inner->is_valid_counted_loop(T_INT) && inner->is_strip_mined()) failed: OuterStripMinedLoop should have been removed

Your commit was automatically rebased without conflicts.

Pushed as commit c569f1d.

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants