-
Notifications
You must be signed in to change notification settings - Fork 563
8373688: Wrong render scale is used if Window is on another screen when Scene is sized #2007
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
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back jhendrikx! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
|
This fix introduces another issue in the monkey tester, breaking the layout (see the screenshot below). The failure can be seen when the MT window appears on the primary (scale=2) as well as on the secondary (scale=1) monitor, running macOS 26.1. The layout gets fixed when the user resizes the window. Interestingly, moving the window to another screen with a different scale does not fixes the issue.
More observations:
|
|
@andy-goryachev-oracle Well, this is going a bit beyond what I'm trying to fix. I don't see any of the issues you're showing, not with test programs, nor with MonkeyTester. In fact, I saw several positive things after applying this fix (Windows are no longer sized with unused empty space when immediately shown on a different monitor). As this again seems to be Mac specific, I have very limited means to "fix" this further, so perhaps you could have a look yourself. I've added some debug output that will be helpful (you can share it here). Look specifically at what MonkeyTester is setting X/Y/width/height of its Window explicitly when it has some settings stored from a previous run. This means it generally follows a slightly different code path when the window is shown, since all the "explicit" flags for x, y, width and height will be true. Still, that doesn't explain how you get some unused empty space. Here's an example of the output on my system, where MonkeyTester is shown on the 1.0 monitor on the right side of a 1.5 monitor: What you see above here is that initially the window screen is still the primary screen (at minXY=0,0); after Come to think of it, the scene size call is basically superfluous; if width/height is explicit, we could skip that completely. Anyway, let me know what you find. I'm not seeing any issues with the above outputs, but perhaps something odd pops up on your system that may point us in the right direction. |
|
We also need this checked on Linux[es] |
|
@andy-goryachev-oracle |
|
Note: I am using the latest standalone monkey tester https://github.com/andy-goryachev-oracle/MonkeyTest but a similar issue is present in the one that's currently in the main repo. |
|
Judging from how square the MT screen looks (700 x 700 orso), it seems that after the window is shown, it is not resizing it to fit the window. It is actually keeping the It's certainly odd, since I'm only moving the |
|
Can skip this comment, it's outdated as PopupWindow tests were failing with this change @andy-goryachev-oracle Thanks for taking the time to test this. I think I may have a fix, included in this PR (I left the print statements in for now). It was again a Mac specific problem, that I couldn't reproduce on Windows. Luckily I could borrow the mac again (and my stuff was still on it). The difference between Mac and Windows here was the layout flag status on the Scene root after the Window was shown. On Mac it was How this difference arises is probably somewhere in the peer code or native code. On Windows, some control (or perhaps the Scene) probably receives a signal that it should relayout itself when the Window shows, which bubbles up to the root, and the root gets The solution is luckily much simpler. I was already suspicious of the fact that we ask the Scene to "size itself" in all situations, even if both the width and height of the Window were set explicitly -- this happens with the somewhat poorly named So, the fix is to only call Let me know if this resolves the problem for you as well Andy. |
|
@andy-goryachev-oracle my first fix broke PopupWindow sizing code; it apparently relies on the scene being sized despite setting a fixed Window width/height. I feel that code is too intertwined to touch, so I decided to go for a different approach. New approach: Instead of using The scene is then sized (as before) with the correct render scales in order to fix the ellipsis issue. The So:
I think this new solution avoids many pitfalls, and is still a simple fix. |
|
On macOS the window's size is tracked in logical coordinates, not pixels. When you move a window to another screen you typically won't get Can't test this on Linux right now. Something is going wrong when Linux is configured with multiple screens at different scales. JavaFX recognizes when a window changes screens but doesn't update the window size or scaling factors. |
|
@andy-goryachev-oracle Could you have another look? I think this fixes all issues, and we may be able to proceed with #1945 then. If you agree, I'll remove the debug lines so it can be reviewed. |
|
yes, I was planning to take a look at this today |
|
FWIW this can't be tested on Linux at the moment. It's possible to set up a system with multiple monitors each with a different scale but due to limitations in the GTK3 API we have to choose between supporting fractional scaling or per-monitor scaling. Currently we favor fractional and so we use the same scaling factor across all monitors. |
|
Looks good on macOS and Windows, I see no ill effects opening the monkey tester on external/internal screens with various scale factors. I've tested this branch merged with the latest master (please sync up the long running branches with the master). Also, please update the (c) to 2026 when you'll be removing the debug printouts. |
|
@beldenfox do you see any issues/regressions with/without an external monitor on linux? |
|
@hjohn This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
I don't think this will cause any problems on Linux, but does a fix an issue on Mac. |



When a Window is created with a certain X/Y coordinate to place it on a specific screen, and is subsequently shown for the first time, one of the first things it does is size the window according to the size of the Scene. It does this based on the render scale of the primary screen as it has not moved the peer yet to the correct screen. After the scene has been sized, it is moved to the correct screen, triggering a change of render scale, but not a resizing of the Window (as this is only done once).
The result of this is that due to slight difference in render scale, the size calculated for the scene may be a few pixels off. As the scene's preferred size is used for this calculation, even a few pixels too small can result in Labels being shown with ellipsis on the intended target screen with a different render scale.
When observing the render scale X or Y property, one can observe a change from 1.0 (the default value) to 2.0 (the primary screen's render scale) to another value (depending on the target screen). However, the Window involved (being positioned by the user using setX()/setY() before it is shown) was never shown on the primary screen, yet the size calculation assumed it was.
To solve this problem, the peer should be moved to the correct screen before asking the Scene for its preferred size to use as the initial Window size. Doing so (by adding an additional
applyBoundscall) also results in the render scale properties to only change once (or not at all) from their default value to the target screen's value (or not at all if the target screen is 1.0 scale).Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2007/head:pull/2007$ git checkout pull/2007Update a local copy of the PR:
$ git checkout pull/2007$ git pull https://git.openjdk.org/jfx.git pull/2007/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2007View PR using the GUI difftool:
$ git pr show -t 2007Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2007.diff
Using Webrev
Link to Webrev Comment