Skip to content

8335468: [XWayland] JavaFX hangs when calling java.awt.Robot.getPixelColor #22131

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

Conversation

azvegint
Copy link
Member

@azvegint azvegint commented Nov 15, 2024

This is a linux only issue and this PR contains two parts(they are available as two separate commits):

a. 8335468: [XWayland] JavaFX hangs when calling java.awt.Robot.getPixelColor
b. 8335469: [XWayland] crash when an AWT ScreenCast session overlaps with an FX ScreenCast session

b. is not reproducible without a. being fixed.

More about both cases:


a.

Previously we used a blocking g_main_context_iteration call, this prevents normal execution if there is a GTK main loop running in the process.

Now we are handling 3 cases:

  1. If there is no GTK main loop running
    Example: just a JDK only application.
    In this case we call g_main_context_iteration(NULL, TRUE) as before (when gtk_main_level() == 0).

  2. If there is a GTK main loop running, but we are not requesting pixels on its thread
    Example: application showing a JFXPanel, but are requesting pixels from a main thread.
    Now we are not trying to block thread: g_main_context_iteration(NULL, FALSE) (when gtk_main_level() > 0) .

  3. If there is a GTK main loop running, and we are requesting pixels on its thread
    Example: a JavaFX application trying to get pixels on the FX application thread, e.g. from a button callback.
    Now we go nested with gtk_main()

jdk commit


b.

After fixing a. the crash appears:

Internally the ScreenCast session keeps open for 2s (both JDK and JFX, and their implementations are almost identical).
This is to reduce overhead in case of frequent consecutive screen captures.

When we perform a cleanup to close the session, we internally call pw_deinit.

It becomes a problem if these sessions overlap in time, so that the second session cleanup crashes when it tries to call pipewire functions without initializing the pipewire system by pw_init (please note that This function can be called multiple times.).

So the solution is not to call pw_deinit because we don't really need it, and it needs to be applied to both the JDK and JavaFX.

jdk commit / jfx commit
FX review counterpart


Testing in different scenarios looks good.


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-8335468: [XWayland] JavaFX hangs when calling java.awt.Robot.getPixelColor (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22131

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 15, 2024

👋 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.

@openjdk
Copy link

openjdk bot commented Nov 15, 2024

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

8335468: [XWayland] JavaFX hangs when calling java.awt.Robot.getPixelColor

Reviewed-by: kcr, honkar

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

  • 7be94d0: 8344891: Remove uses of sun.misc.ReflectUtil in java.desktop
  • 822a155: 8341427: JFR: Adjust object sampler span handling
  • d00f311: 8343150: Change URLClassLoader.getPermissions to return empty PermissionCollection
  • effee12: 8344533: CTW: Add option to remove clinits before loading
  • 70c4e2c: 8344587: Reduce number of "jdk.jpackage.internal" classes used from other packages
  • 1114704: 6672644: JComboBox still scrolling if switch to another window and return back
  • 98b6678: 8343741: SA jstack --mixed should print information about VM locks
  • 1b2d9ca: 8344881: Problemlist java/awt/Robot/InfiniteLoopException.java on Linux
  • 6aec2dc: 8344788: Specify that the access control context parameters of Subject.doAsPrivileged are ignored
  • 079f503: 8344568: Renaming ceil_log2 to log2i_ceil
  • ... and 190 more: https://git.openjdk.org/jdk/compare/db56266ad164b4ecae59451dc0a832097dbfbd8e...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 Nov 15, 2024

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

@azvegint azvegint marked this pull request as ready for review November 15, 2024 02:06
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 15, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 15, 2024

Webrevs

@kevinrushforth kevinrushforth self-requested a review November 15, 2024 12:44
Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Looks good. I tested it on an Ubuntu 24.04 system running Wayland both with and without the FX fix in openjdk/jfx#1639

@kevinrushforth
Copy link
Member

@honkar-jdk or @prrace Do one of you want to review this?

@honkar-jdk
Copy link
Contributor

honkar-jdk commented Nov 18, 2024

@honkar-jdk or @prrace Do one of you want to review this?

Sure Kevin. I can take a look at it later today.

@honkar-jdk
Copy link
Contributor

Tested the changes on Ubuntu 24.04 with JDK alone (without JFX fix) and did not observe any issues in Robot related tests (automated + manual). Since this is an interop fix, I'll be testing it JDK + JFX fix next.

Copy link
Contributor

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

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

LGTM, tested without/with jdk fix and without/with jfx fix combinations.
Interop tests work as expected with jdk + jfx fix.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 24, 2024
@azvegint
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 25, 2024

Going to push as commit 965aace.
Since your change was applied there have been 212 commits pushed to the master branch:

  • 811d08c: 8340010: Fix vectorization tests with compact headers
  • 519bb26: 8344217: Remove calls to SecurityManager and doPrivileged in java.net.DatagramSocket and java.net.NetMulticastSocket after JEP 486 integration
  • d112f35: 8344855: Remove calls to SecurityManager and doPrivileged in HTTP related implementation classes in the sun.net and sun.net.www.http packages after JEP 486 integration
  • da4b7a8: 8341436: containers/docker/TestJcmdWithSideCar.java takes needlessly long to run
  • 333a997: 8335231: [macos] Test java/awt/print/PrinterJob/Cancel/PrinterJobCancel.java failed on macOS because the case didn't get the expected PrintAbortException
  • 9576546: 8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status
  • 68ba7ee: 8340205: Native linker allows MemoryLayout consisting of only PaddingLayout
  • 6f622da: 8344923: Problem list on java/awt/Robot/ScreenCaptureRobotTest.java on macOS
  • 8f08020: 8344903: Improve error handling TestJhsdbJstackPrintVMLocks.java
  • a83cfe2: 8344917: Fix recent NULL usage backsliding
  • ... and 202 more: https://git.openjdk.org/jdk/compare/db56266ad164b4ecae59451dc0a832097dbfbd8e...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 25, 2024

@azvegint Pushed as commit 965aace.

💡 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 [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants