Skip to content

8160755: bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F #19381

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

Closed
wants to merge 7 commits into from

Conversation

kumarabhi006
Copy link
Contributor

@kumarabhi006 kumarabhi006 commented May 24, 2024

bug6492108.java test always fails in GTK L&F in single as well as dual screen linux machines. Since this test was not marked as "headful" in it's initial version, it never failed but after the fix of JDK-8287051 this test was problem listed as it always
failed which is captured in the JBS.
The reason of failure is the pixel color mismatch between JEditorPane and JTextArea/JTextPane which is caused by the JEditorPane's default opaque value which is false for GTK3 at L767.
In initial load JEditorPane, JTextArea and JTextPane components are opaque at L718 but after the fix for JDK-8145547 the implementation was changed to provide conditional support for GTK3 on linux where few components like Editor Pane, Formatted text Field, Password Field etc are opaque only if the GTK version is not 3.
JTextPane's issue was observed by JDK-8218479 and then the default opacity is set to true for JTextPane irrespective of GTK version.
Extending the fix in isOpaque() method in GTKStyle.java for JEditorPane similar to JTextPane resolves the issue.

Test verified in both single and dual screen linux machines.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8160755: bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19381/head:pull/19381
$ git checkout pull/19381

Update a local copy of the PR:
$ git checkout pull/19381
$ git pull https://git.openjdk.org/jdk.git pull/19381/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19381

View PR using the GUI difftool:
$ git pr show -t 19381

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19381.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 24, 2024

👋 Welcome back abhiscxk! 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
Copy link

openjdk bot commented May 24, 2024

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

8160755: bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F

Reviewed-by: aivanov, dnguyen, tr

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

  • 9db7c95: 8332750: Broken link in CatalogFeatures.html
  • d826127: 8333462: Performance regression of new DecimalFormat() when compare to jdk11
  • 67b9a08: 8333586: Improve syntax of @see tags in javax.lang.model
  • 244f6ac: 8307824: Clean up Finalizable.java and finalize terminology in vmTestbase/nsk/share
  • a706e35: 8332039: Cannot invoke "com.sun.source.util.DocTreePath.getTreePath()" because "path" is null
  • 612b689: 8043226: Better diagnostics for non-applicable type annotations
  • dce9703: 8333226: Regressions 2-3% in Compress ZGC after 8331253
  • b101dcb: 8333312: Incorrect since tags on new ClassReader and ConstantPool methods
  • e0bab78: 8326951: since-checker - missing @ since tags
  • 31f7039: 8316131: runtime/cds/appcds/TestParallelGCWithCDS.java fails with JNI error
  • ... and 914 more: https://git.openjdk.org/jdk/compare/b9c76dedf4aa2248a5e561a535c9e3e181f7836a...master

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
Copy link

openjdk bot commented May 24, 2024

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

  • client

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.

@openjdk openjdk bot added client client-libs-dev@openjdk.org rfr Pull request is ready for review labels May 24, 2024
@mlbridge
Copy link

mlbridge bot commented May 24, 2024

@kumarabhi006 kumarabhi006 changed the title 8160755: closed/com/sun/java/swing/plaf/gtk/6492108/bug6492108.java test fails in GTK L&F bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F May 24, 2024
@openjdk openjdk bot removed the rfr Pull request is ready for review label May 24, 2024
@kumarabhi006 kumarabhi006 changed the title bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F 8160755: bug6492108.java test fails with exception Image comparison failed at (0, 0) for image 4 in GTK L&F May 24, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label May 24, 2024
addTextComp(parent, text);

text = type.newInstance();
if (showText) text.setText(name + "\ndisabled");
Copy link
Contributor

Choose a reason for hiding this comment

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

showText is never initialized, meaning this condition is never executed. Can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

}
}

public void onBackgroundThread30() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused, can be removed?

Copy link
Contributor Author

@kumarabhi006 kumarabhi006 May 30, 2024

Choose a reason for hiding this comment

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

Actually it is not unused and is run on the background thread to allow enough time for visual verification. I will check once in the CI testing after removing this method and if there is no failure, it can be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I verified with debug, its not used in background thread too. Please do verify once and remove if not used......

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I can see the debug output in my local run.
invoking: onEDT10 onEDT10 invoking: onBackgroundThread20 onBackgroundThread20 invoking: onBackgroundThread30 onBackgroundThread30

But as I told before this may not impact the result of the test, it is just to add extra delay to provide visual verification.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, true..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested in CI and there is no failure for multiple run. Removed this method.

Copy link
Member

@aivanov-jdk aivanov-jdk May 31, 2024

Choose a reason for hiding this comment

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

But as I told before this may not impact the result of the test, it is just to add extra delay to provide visual verification.

In this case, it can be removed.

We want tests to run fast, don't we?

When debugging, it makes sense to increase the delays so that you can see what's going on on the screen.

Tested in CI and there is no failure for multiple run. Removed this method.

Thanks! I noticed it after I had written the comment.

* @summary Verifies that the background is painted the same for
* JTextArea, JTextPane, and JEditorPane.
* @library /javax/swing/regtesthelpers
* @build SwingTestHelper
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this test be marked only for linux?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since test was written originally to run in GTK L&F, updated the test to run only on linux machine.

UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
} catch (Exception e) {
System.out.println("GTK LAF is not supported on this system; test passes");
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be jtreg.testSkipped exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

return panel;
}

private void onEDT10() {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this method required? can it be rewritten to not use onEDT10 and onBackgroundThread20?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be re-written without using onEDT10 and onBackgroundThread20.. but I kept it as it was in original test. Don't see any strong reason to change also and there are many other tests which used SwingTestHelper utility to perform the testing.

private static void addTextComps(Container parent,
Class<? extends JTextComponent> type)
throws Throwable
{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think formatting here looks a little odd, could probably move the bracket onto the same line as throws Throwable and shift it over to the right to match Class<? extends JTextComponent> type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

Previous formatting was less confusing and aligned with Java Coding Style Guidelines.

The parameters to the method are aligned to the opening parenthesis; the throws clause is not part of the parameters and it's placed on another line according to rules of wrapping lines (it should've used double-indentation of 8 spaces rather than 4 spaces to indicate a continuation line).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted back to previous formatting with double-indentation. Hopefully this should be ok now.

Copy link
Member

Choose a reason for hiding this comment

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

This formatting looks good to me.


if (refimg.getWidth() != testimg.getWidth() ||
refimg.getHeight() != testimg.getHeight())
{
Copy link
Contributor

Choose a reason for hiding this comment

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

move bracket to previous line to be consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially I thought of doing so but in one of the PR it was mentioned that "We generally prefer the { on a new line if the conditional is multi-line" #18703 (comment).

So I left like that.

Copy link
Member

Choose a reason for hiding this comment

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

I can't say that “We generally prefer the { on a new line if the conditional is multi-line” really holds, yet I agree it makes code less confusing by separating the condition and its continuation lines from the inside block.

To make the continuation line stand out as continuation line, place the || at the start of wrapped line.

Again, there's no agreed upon set of style guidelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make the continuation line stand out as continuation line, place the || at the start of wrapped line.

Updated.

@kumarabhi006
Copy link
Contributor Author

@aivanov-jdk @alisenchung All review comments are addressed. Please review.

Comment on lines 63 to 64
throw new SkippedException("GTK LAF is not supported on this system;" +
" test passes");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw new SkippedException("GTK LAF is not supported on this system;" +
" test passes");
throw new SkippedException("GTK LAF is not supported on this system");

I'd remove the additional message. I believe it was println before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

private static void addTextComps(Container parent,
Class<? extends JTextComponent> type)
throws Throwable
{
Copy link
Member

Choose a reason for hiding this comment

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

This formatting looks good to me.

Comment on lines 123 to 124
Rectangle refRect =
new Rectangle(loc.x, loc.y, ref.getWidth(), ref.getHeight());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Rectangle refRect =
new Rectangle(loc.x, loc.y, ref.getWidth(), ref.getHeight());
Rectangle refRect = new Rectangle(loc, ref.getSize());

requestAndWaitForFocus(panel);
}

private void onBackgroundThread20() {
Copy link
Member

Choose a reason for hiding this comment

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

This method should run on EDT because it accesses the state of the components.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to run this on EDT.

Comment on lines 136 to 137
if (refimg.getWidth() != testimg.getWidth()
|| refimg.getHeight() != testimg.getHeight())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (refimg.getWidth() != testimg.getWidth()
|| refimg.getHeight() != testimg.getHeight())
if (refimg.getWidth() != testimg.getWidth()
|| refimg.getHeight() != testimg.getHeight())

One more space, it should be aligned to the inside of the parenthesis.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used Util to compare images, so these lines are removed now.

Comment on lines 130 to 133
loc = test.getLocationOnScreen();
Rectangle testRect =
new Rectangle(loc.x, loc.y,
test.getWidth(), test.getHeight());
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
loc = test.getLocationOnScreen();
Rectangle testRect =
new Rectangle(loc.x, loc.y,
test.getWidth(), test.getHeight());
loc = test.getLocationOnScreen();
Rectangle testRect = new Rectangle(test.getLocationOnScreen(),
test.getSize());

Choose one style and adjust both statements, refRect and testRect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to use same style for both places.

test.getWidth(), test.getHeight());
BufferedImage testimg = robot.createScreenCapture(testRect);

if (refimg.getWidth() != testimg.getWidth()
Copy link
Member

Choose a reason for hiding this comment

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

I suggest moving the part that compares the images into a helper method. Alternatively, you can use Util.compareBufferedImages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.. Updated Util.compareBufferedImages to compare images.

Comment on lines 147 to 148
fail("Image comparison failed at (" +
x + "," + y + ") for image " + index);
Copy link
Member

Choose a reason for hiding this comment

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

Adding count and k to diagnostic message could help identifying the failing case quicker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't find adding k to diagnostic message useful.. failure message is more relevant now about the images which are compared.

Copy link
Member

Choose a reason for hiding this comment

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

The images themselves are more useful for sure. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

You should update the copyright year.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

Choose a reason for hiding this comment

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

I can't see it in the PR. Didn't push?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my bad, I missed to add that changes. Pushed now.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 4, 2024
Copy link
Contributor

@DamonGuy DamonGuy left a comment

Choose a reason for hiding this comment

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

Ran bug6492108.java with changes. LGTM.

Copy link
Contributor

@TejeshR13 TejeshR13 left a comment

Choose a reason for hiding this comment

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

LGTM.

@kumarabhi006
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 5, 2024

Going to push as commit 5dcb7a6.
Since your change was applied there have been 943 commits pushed to the master branch:

  • 438121b: 8332785: Replace naked uses of UseSharedSpaces with CDSConfig::is_using_archive
  • d7d1afb: 8206447: InflaterInputStream.skip receives long but it's limited to Integer.MAX_VALUE
  • 7acfba2: 8327650: Test java/nio/channels/DatagramChannel/StressNativeSignal.java timed out
  • c5c0867: 8333252: C2: assert(assertion_predicate_has_loop_opaque_node(iff)) failed: must find OpaqueLoop* nodes
  • d85b0ca: 8332457: Examine startup overheads from JDK-8294961
  • 326dbb1: 8312436: CompletableFuture never completes when 'Throwable.toString()' method throws Exception
  • 9a8096f: 8330047: ASAN build error with gcc 13
  • 6882b38: 8333590: UnmodifiableHeaders.toString() returns a value that represents empty headers
  • cbb6747: 8329581: Java launcher no longer prints a stack trace
  • 789f704: 8322732: ForkJoinPool may underutilize cores in async mode
  • ... and 933 more: https://git.openjdk.org/jdk/compare/b9c76dedf4aa2248a5e561a535c9e3e181f7836a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 5, 2024
@openjdk openjdk bot closed this Jun 5, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 5, 2024
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jun 5, 2024
@openjdk
Copy link

openjdk bot commented Jun 5, 2024

@kumarabhi006 Pushed as commit 5dcb7a6.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants