-
Notifications
You must be signed in to change notification settings - Fork 443
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
8326712: Robot tests fail on XWayland #1490
Conversation
👋 Welcome back azvegint! A progress list of the required criteria for merging this PR into |
@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:
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 1 new commit pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
tests/system/src/test/java/test/robot/javafx/embed/swing/SwingNodeJDialogTest.java
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/ScreencastHelper.java
Outdated
Show resolved
Hide resolved
private TokenStorage() {} | ||
|
||
private static final String REL_NAME = | ||
".fx/robot/screencast-tokens.properties"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be .javafx
However I think we can try to READ .awt (and .java) first and if it exists try to use that.
Perhaps WRITE .javafx ?
If we don't understand what is at .awt or .java then we would then READ .javafx and if it is not there or
doesn't work CREATE .javafx
The overall intent is that if a user authorised Java for AWT then we don't need to re-ask them for FX so long as we can parse what is there and it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to check two locations:
.java/.robot/screencast-tokens.properties
- the default, should be used by both OpenJDK and JavaFx.awt/robot/screencast-tokens.properties
- this is currently the only location used by OpenJDK, but it should be changed to the first location after JDK-8335267 is resolved.
If there is a writable file at location #2
, we won't try to read or write to location #1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a cursory review, just looking at the changes since the first two commits, and it looks fine. Preliminary testing looks good.
I think this is ready to take out of Draft.
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkRobot.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java
Outdated
Show resolved
Hide resolved
We'll want extra pairs of eyes on this one (so at least two "R"eviewers). I'd also like Gluon to verify that it builds on their CI system. Reviewers: @kevinrushforth @prrace @tiainen /reviewers 2 reviewers |
@kevinrushforth |
@azvegint When you do take it out of Draft, please write up something in the Description about the changes as a help to those who will be reviewing it. Also, can you merge in the latest master? In particular, I want to see a GHA run with the |
…here is no writable file on the primary path.
throw new SecurityException( | ||
"Screen Capture in the selected area was not allowed" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kevinrushforth
I think this SecurityException should be removed, as it is not mentioned in the javadoc for the getPixelColor
or getScreenCapture
. And we also do not want to throw another runtime exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the SecurityException is not thrown, how does the caller of getRGBPixels
knows that the result will not be correct because of the missing permission? (as opposed to being incorrect due to a failure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the SecurityException is not thrown, how does the caller of getRGBPixels knows that the result will not be correct because of the missing permission? (as opposed to being incorrect due to a failure)
He won't know it. An indirect result of failure can be a black image.
The current documentation documentation specifies only IllegalStateException and NullPointerException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since SecurityException
is deprecated, we should not throw that.
In a similar situation on macOS (user has not enabled screen capture), we return a blank (all black) image, so I think that's what we would do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to return a blank image if permission is not granted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since
SecurityException
is deprecated, we should not throw that.In a similar situation on macOS (user has not enabled screen capture), we return a blank (all black) image, so I think that's what we would do here.
No, SecurityException is NOT deprecated and there are no plans to deprecate it.
This kind of platform reason for a "SecurityException" is precisely why it isn't deprecated even though the Java SecurityManager is deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the correction about "SecurityException" not being deprecated.
I still think that for this PR, we should not throw an exception, since we A) don't specify it to do so, and B) don't do that on macOS in a nearly identical situation.
We could consider a future RFE to change the spec (and maybe the behavior).
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkRobot.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java
Outdated
Show resolved
Hide resolved
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build still works as expected and documented on our CI infrastructure.
Just of out curiosity, please don't mind it too much: Why the piperwire include files are included? Since the infraestucture should be present for it to work (pipewire is quite new and not present on older linux distributions) a runtime check is needed anyways. What's the advantage of calling dbus functions directly and not use libportal? |
This is mostly a copy and paste of the OpenJDK code, which should be able to be built on fairly old Linux distributions (consider OpenJDK backports to earlier versions), and we didn't want to add any new external dependencies there. |
The code changes all look good. I've done a fair bit of testing already, and will finish up my testing tomorrow. |
// Emulating mouse clicks on XWayland with XTEST does not currently affect the Wayland compositor, | ||
// so trying to click on the window title or window body will not bring the window to the front. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same issue we have in OpenJDK, when the emulated mouse click doesn't put one window in front of another.
After this fix and applying a fix for the hang issue, all the SwingNodeJDialogTest
tests are passing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing is complete. No new issues. I only see the SwingNodeJDialogTest
failure.
I did leave one minor naming comment and will reapprove if you make the suggested change.
modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/screencast/TokenStorage.java
Outdated
Show resolved
Hide resolved
/integrate |
Going to push as commit 459b15f.
Your commit was automatically rebased without conflicts. |
this.height = height; | ||
} | ||
|
||
public boolean equals(Object obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JDK-8335633
Missing @OverRide in Dimension
Most of the headful test failures on XWayland are due to screen capture is not working.
Wayland, unlike X11, does not allow arbitrary applications to capture the screen contents directly.
Instead, screen capture functionality is managed by the compositor, which can enforce stricter controls and permissions, requiring explicit user approval for screen capture operations.
This issue is already resolved in OpenJDK (base issue, there are subsequent fixes) by using the ScreenCast XDG portal.
The XDG ScreenCast portal is utilized for capturing screen data as it provides a secure and standardized method for applications to access screen content.
Additionally, it allows for the reuse of user permissions without requiring repeated confirmations, streamlining the user experience and enhancing convenience.
So this changeset is a copy of the OpenJDK fixes with the addition of the JavaFX customization.
For ease of review, you can skip the changes in the first two commits:
gtk-
prefix before thegtk_...
andg_...
function calls (in AWT all gtk functions are dynamically loaded, we don't need that in JavaFX).properties added:
javafx.robot.screenshotMethod
, acceptsgtk
(existing gtk method) anddbusScreencast
(added by this changeset, used by default for Wayland)javafx.robot.screenshotDebug
prints debug info if it is set totrue
What are the remaining issues?
After applying this fix, system tests will pass except for the
SwingNodeJDialogTest
test.This interop test calls
java.awt.Robot#getPixelColor
which internallygtk->g_main_context_iteration(NULL, TRUE);
causes a blocking of javafx gtk loop, so the test hangs.So a change is required on OpenJDK side to fix this issue.
Even after solving the
#1
, theSwingNodeJDialogTest.testNodeRemovalBeforeShow
case is still failing.Internally the ScreenCast session keeps open for 2s.
This is to reduce overhead in case of frequent consecutive screen captures.
There is a crash when an AWT ScreenCast session overlaps with the FX ScreenCast session. E.g.
java.awt.Robot#getPixelColor()
andjavafx.scene.robot.Robot#getPixelColor()
are called within 1 second.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1490/head:pull/1490
$ git checkout pull/1490
Update a local copy of the PR:
$ git checkout pull/1490
$ git pull https://git.openjdk.org/jfx.git pull/1490/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1490
View PR using the GUI difftool:
$ git pr show -t 1490
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1490.diff
Webrev
Link to Webrev Comment