Skip to content

8352149: Test java/awt/Frame/MultiScreenTest.java fails: Window list is empty #24752

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

kboulanou
Copy link

@kboulanou kboulanou commented Apr 18, 2025

Fixes issue in which the test fails when run on multi-screen machine.

Tested on Ubuntu 24.04, MacOS 15 and Windows 11

JTREG

runner starting test: java/awt/Frame/MultiScreenTest.java
runner finished test: java/awt/Frame/MultiScreenTest.java
Passed. Execution successful


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-8352149: Test java/awt/Frame/MultiScreenTest.java fails: Window list is empty (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24752

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@kboulanou
Copy link
Author

/covered

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 18, 2025

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 18, 2025

You are already a known contributor!

@openjdk
Copy link

openjdk bot commented Apr 18, 2025

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

8352149: Test java/awt/Frame/MultiScreenTest.java fails: Window list is empty

Reviewed-by: aivanov, abhiscxk

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

  • b2e7cda: 8358171: Additional code coverage for PEM API
  • 65fda5c: 8358593: Add ucontext accessors for *BSD on Aarch64
  • d1b7880: 8357951: Remove the IdealLoopTree* loop parameter from PhaseIdealLoop::loop_iv_phi

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@sendaoYan, @kumarabhi006, @aivanov-jdk) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot changed the title 8352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails in M… 8352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails in MacOS Apr 18, 2025
@openjdk
Copy link

openjdk bot commented Apr 18, 2025

@kboulanou 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.

Copy link
Member

@sendaoYan sendaoYan left a comment

Choose a reason for hiding this comment

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

Copy right year should be updated.

@kboulanou kboulanou marked this pull request as ready for review April 23, 2025 10:09
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 23, 2025
@mlbridge
Copy link

mlbridge bot commented Apr 23, 2025

}
GraphicsConfiguration[] gc = primaryDevice.getConfigurations();
if (gc.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the for-loop?

I tested your changes on multi-monitor system on Linux platform but don't see any frames created for second screen. There is only one frame created for primary screen.

@kumarabhi006
Copy link
Contributor

This test was failing on Solaris platform as per JDK-4312921 and the test should create multiple frames on second screen.

I converted the test from applet to manual test under this issue. As per original applet test instruction, This test is to be run only on multiscreen Solaris machine. Since Solaris is no longer supported, this test was supposed to verify on Linux.

I couldn't check this test on all platforms (didn't have the multi-monitor setup) and made this to run on all platforms but I think this test should be restricted to run only on Linux machine.

I ran the test (without your fix) on Windows, Mac and Linux platform. It failed on Windows and Mac but no issues on Linux.

I suggest to revert back the changes and restrict the test to run only on Linux machine.

@kboulanou
Copy link
Author

Changes reverted

Copyright year updated.
@requires os.family == "linux" added

@kumarabhi006
Copy link
Contributor

Please update the title of the PR to 8352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails

@kboulanou kboulanou changed the title 8352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails in MacOS 352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails Apr 24, 2025
@kboulanou kboulanou changed the title 352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails 8352149: open/test/jdk/java/awt/Frame/MultiScreenTest.java fails Apr 24, 2025
@kboulanou
Copy link
Author

PR title updated

Copy link
Contributor

@kumarabhi006 kumarabhi006 left a comment

Choose a reason for hiding this comment

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

LGTM.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 25, 2025
@aivanov-jdk
Copy link
Member

aivanov-jdk commented Apr 26, 2025

The test doesn't work on Linux either. The problem on Linux is that there are too many graphics configurations are returned.

On my Fedora Linux 42 with two monitors, gs[j].getConfigurations() returns an array of length 176.

It could be the reason why the loop divides the number of configurations: gc.length / 2.

In the end, this loop creates 176 windows and a thread for each of the windows. This hangs GNOME shell completely. A few times, I was able to kill the java process via SSH connection, but it doesn't always help, and it still takes quite a while to get back to responsive UI.

I'm sure this problem was discussed somewhere… (I'll search for that discussion later.) We should limit testing to default configurations only.

As for Windows, the test could be usable on Windows and macOS if you remove replace < gc.length / 2 with < gc.length as @kboulanou suggested initially. On Windows and macOS, there's usually only one configuration returned from gs[j].getConfigurations() for each screen.

@kumarabhi006
Copy link
Contributor

The test doesn't work on Linux either. The problem on Linux is that there are too many graphics configurations are returned.

On my Fedora Linux 42 with two monitors, gs[j].getConfigurations() returns an array of length 176.

It could be the reason why the loop divides the number of configurations: gc.length / 2.

In the end, this loop creates 176 window and a thread for each of the windows. This hangs GNOME shell completely. A few times, I was able to kill the java process via SSH connection, but it doesn't always help, and it still takes quite a while to get back to responsive UI.

I'm sure this problem was discussed somewhere… (I'll search for that discussion later.) We should limit testing to default configurations only.

As for Windows, the test could be usable on Windows and macOS if you remove replace < gc.length / 2 with < gc.length as @kboulanou suggested initially. On Windows and macOS, there's usually only one configuration returned from gs[j].getConfigurations() for each screen.

I tested on Ubuntu 22.04 and don't find any issues. gs[j].getConfigurations() returns an array of length 120, it took sometime to get back to responsive UI but the waiting time is not that much.
Seems creating another 38 windows and a thread for each window causing more overhead in your case.

I agree that gc.length/2 is to reduce the number of frames created on the screen to avoid the hang.
If the testing doesn't require so many frames to create then it can be reduced for linux as well (may be 5 or something based on the gc.length returned from `gs[j].getConfigurations().

Since the original bug was raised for Solaris, I suggested to drop the testing for Windows and Mac.

As per the bug description, The picture is: No images or few images showed up on the second screen, but the first screen is messed up with images and text strings everywhere., my assumption is creating multiple frames with images and text strings may be the requirement (although it's not clearly mentioned).

@aivanov-jdk If we replace < gc.length / 2 with < gc.length on Windows and Mac, we will have less frames to test. I agree this will make the test to run but will it add any value to it ?

@aivanov-jdk
Copy link
Member

I tested on Ubuntu 22.04 and don't find any issues. gs[j].getConfigurations() returns an array of length 120, it took sometime to get back to responsive UI but the waiting time is not that much. Seems creating another 38 windows and a thread for each window causing more overhead in your case.

I'm pretty sure it depends on hardware: how many configurations are returned and how easy the OS and CPU can handle lots of threads.

I agree that gc.length/2 is to reduce the number of frames created on the screen to avoid the hang. If the testing doesn't require so many frames to create then it can be reduced for linux as well (may be 5 or something based on the gc.length returned from `gs[j].getConfigurations().

I don't see how such a huge number of windows can possibly improve testing.

I'd say testing the default configuration which is the current one for the screen should be enough.

Since the original bug was raised for Solaris, I suggested to drop the testing for Windows and Mac.

As per the bug description, The picture is: No images or few images showed up on the second screen, but the first screen is messed up with images and text strings everywhere., my assumption is creating multiple frames with images and text strings may be the requirement (although it's not clearly mentioned).

I do not think so.

@aivanov-jdk If we replace < gc.length / 2 with < gc.length on Windows and Mac, we will have less frames to test. I agree this will make the test to run but will it add any value to it ?

As it looks, the test isn't valuable in its current state either way.

I don't think we'll be able to reproduce the original problem, yet it may be possible.

The bug description states,

No images or few images showed up on the second screen, but the first screen is messed up with images and text strings everywhere. Those wrong text strings and images stay on the first screen even after the screenTest application terminated. It seems not like the repaint problem since the images were drawn to the wrong place at the first beginning.

Then Phil says in his comment,

The DGA docs are VERY misleading … indicate that the file descriptor returned from dga_draw_devfd is per device. This is not always so as we discovered.

This could indicate that the issue is for Solaris only. However, dga_draw_devfd seems to be an X Server API, thus it may be applicable to Linux.

So, it's unclear whether the test could reproduce the original problem on Solaris. If it doesn't, removing the test is the solution.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 28, 2025
@kumarabhi006
Copy link
Contributor

So, it's unclear whether the test could reproduce the original problem on Solaris. If it doesn't, removing the test is the solution.

I removed the test initially but later on added as it was suggested to test it for Linux.

@kumarabhi006
Copy link
Contributor

@aivanov-jdk In that case, test can be modified to run for default configuration for all platforms.

@aivanov-jdk
Copy link
Member

aivanov-jdk commented Apr 29, 2025

I'm sure this problem was discussed somewhere… (I'll search for that discussion later.) We should limit testing to default configurations only.

It was in #21942, its description reads

I think the large number of XVisuals may have something to do with it.
I've updated it quite a bit and limited the number of dialogs it creates - we really don't need to test 300 of them

The updated code reduces the number of tested graphics configurations to 10:

/* Don't want to run too long. Test the default and up to 10 more */
GraphicsConfiguration[] configs = gd.getConfigurations();
for (int c = 0; c < configs.length && c < 10; c++) {
test(configs[c]);
}

@kumarabhi006
Copy link
Contributor

#21942

Thanks @aivanov-jdk for suggesting the correct route.

@kboulanou Please modify the test to run for all platforms and you can limit the number of graphics configuration to 10 for linux.

@kboulanou
Copy link
Author

@kumarabhi006 Changes done and tested on MacOS.

Will test on Linux and Windows next.

@kboulanou
Copy link
Author

Updates to this PR:
1- Title changed to be meaningful for this PR
2- Override annotation added
3- Space inserted before comments.

@mrserb
Copy link
Member

mrserb commented May 13, 2025

I ran the test (without your fix) on Windows, Mac and Linux platform. It failed on Windows and Mac but no issues on Linux.

Why it fails on win/mac?

@kumarabhi006
Copy link
Contributor

I ran the test (without your fix) on Windows, Mac and Linux platform. It failed on Windows and Mac but no issues on Linux.

Why it fails on win/mac?

On Win/mac, graphic configuration return value is 1 and then there is no frame created as gc.length/2 evaluates to 0.

Copy link
Contributor

@kumarabhi006 kumarabhi006 left a comment

Choose a reason for hiding this comment

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

You may remove setting the title for instruction and row count for PassFailJFrame.

JFrame f = new JFrame(gc[i]); //test JFrame( gc )
GCCanvas c = new GCCanvas(gc[i]);//test canvas( gc )
Rectangle gcBounds = gc[i].getBounds(); //test getBounds()
GCCanvas c = new GCCanvas(gc[i]);// test canvas( gc )
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency

Suggested change
GCCanvas c = new GCCanvas(gc[i]);// test canvas( gc )
GCCanvas c = new GCCanvas(gc[i]); // test canvas( gc )

@@ -99,21 +99,22 @@ public List<JFrame> init() {
for (int j = 0; j < gs.length; j++) {
GraphicsConfiguration[] gc = gs[j].getConfigurations();
if (gc.length > 0) {
for (int i = 0; i < gc.length / 2; i++) {
for (int i = 0; i < gc.length && i < 10; i++) {
JFrame f = new JFrame(gc[i]); //test JFrame( gc )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
JFrame f = new JFrame(gc[i]); //test JFrame( gc )
JFrame f = new JFrame(gc[i]); // test JFrame( gc )

int xoffs = gcBounds.x;
int yoffs = gcBounds.y;

f.getContentPane().add(c);
f.setTitle("Screen# " + Integer.toString(j) + ", GC#" + Integer.toString(i));
f.setSize(300, 200);
f.setLocation(400 + xoffs, (i * 150) + yoffs);//test displaying in right location
f.setLocation(400 + xoffs, (i * 150) + yoffs);// test
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f.setLocation(400 + xoffs, (i * 150) + yoffs);// test
f.setLocation(400 + xoffs, (i * 150) + yoffs); // test

@@ -173,7 +175,7 @@ public void paint( Graphics _g ) {
g.setColor(Color.cyan);
g.fillArc(150, 30, 30, 30, 0, 200);
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

You may add a blank line before @Override line to maintain consistency. Also add 4 spaces to move @Override similar to other methods

Suggested change
@Override
@Override

@kboulanou
Copy link
Author

@kumarabhi006 I made changes as you requested. Thanks.

Copy link
Contributor

@kumarabhi006 kumarabhi006 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

There are other code clean-up that can be done, but these issues are close to lines which are modified.

Comment on lines 110 to 111
f.setLocation(400 + xoffs, (i * 150) + yoffs); // test
// displaying in right location
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
f.setLocation(400 + xoffs, (i * 150) + yoffs); // test
// displaying in right location
// test displaying in right location
f.setLocation(400 + xoffs, (i * 150) + yoffs);

The comment applies to this line, however, does it add anything, does it clarify anything? Should we remove the comment?

Copy link
Author

Choose a reason for hiding this comment

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

Comment cleanup done, pending decision about its removal.

Comment on lines 90 to 91
.testUI(obj::init)
.build()
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
.testUI(obj::init)
.build()
.testUI(obj::init)
.positionTestUI(MultiScreenTest::positionTestWindows)
.build()

where

    private static void positionTestWindows(List<Window> testWindows,
                                            PassFailJFrame.InstructionUI instructionUI) {
        // Do nothing - the location of each window is set when they're created
    }

This allows keeping both created frames / windows Screen# and DitherTest GC# together for each screen.

Perhaps, such a null layout should be added as library method into WindowLayouts.java.

Copy link
Author

Choose a reason for hiding this comment

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

Method created and code updated.

@kboulanou
Copy link
Author

@aivanov-jdk updates made as suggested. Thanks.

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

Just minor comments.

Update the subject of the PR to align with the JBS subject.

@kboulanou kboulanou changed the title 8352149: Test java/awt/Frame/MultiScreenTest.java generates too many frames on Linux 8352149: Test java/awt/Frame/MultiScreenTest.java fails: Window list is empty Jun 5, 2025
@kboulanou
Copy link
Author

Title updated as requested.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 6, 2025
@kboulanou
Copy link
Author

@aivanov-jdk May I go ahead and issue integrate command to this PR ?

@aivanov-jdk
Copy link
Member

@aivanov-jdk May I go ahead and issue integrate command to this PR ?

Yes. I'll leave the PR open for a while before I sponsor it to give anyone else to look at the updated code.

@kboulanou
Copy link
Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jun 6, 2025
@openjdk
Copy link

openjdk bot commented Jun 6, 2025

@kboulanou
Your change (at version 44a839b) is now ready to be sponsored by a Committer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client [email protected] ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored
Development

Successfully merging this pull request may close these issues.

5 participants