-
Notifications
You must be signed in to change notification settings - Fork 484
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
8343398: Add reducedData preference #1656
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request. @mstr2 please create a CSR request for issue JDK-8343398 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
Webrevs
|
This PR also includes a small refactor of the GTK and macOS The previous implementations had some parts of the change notification mechanism implemented outside of |
It works on my 14.6 machine. Let me try upgrading and testing again... |
I might suggest adding the instructions on how to control the platform settings as comments somewhere in the implementation.
|
(I've merged the latest master prior to testing) |
It also works on 15.1.1 on my machine. Just to check the obvious: did you close the WiFi Details window? The settings are only applied when you click OK. |
Update: I was getting interference from the VPN application. Getting off the VPN helped - I see the property and ( |
That's the expected result. |
I feel this wouldn't age well, considering that the particular UI used by the different operating systems has often changed over the years. |
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.
It looks like the scope of this change goes far beyond adding a few properties. It looks like a non-trivial refactoring that might also impact other platform preferences.
I did check that switching between light/dark modes on macOS results in proper updates, but the native code needs to be re-reviewed.
@@ -204,6 +187,7 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification | |||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |||
{ | |||
// unblock main thread. Glass is started at this point. | |||
self->platformSupport = [[PlatformSupport alloc] initWithEnv:env application:jApplication]; |
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 we check for failure here? (alloc)
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.
We never do that in obj-c native code, so this probably wouldn't be the place to start. In any case, a failure at this point wouldn't lead to a crash, as the only access of platformSupport
checks for nil
.
I think it has merit. Now that we need to re-test the functionality, it would have helped. Even when something changes, it will be easier to look up a few missing pieces than dig through the PRs... |
I think this sort of information is better suited for a Wiki. Btw, I can review the native code changes. Just not for a couple days. |
tested macOS behavior, all is well. BTW, I've updated the Monkey Tester to highlight changes in Tools -> Platform Preferences Monitor. |
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.
tested on macOS. needs testing on linux and windows.
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 changes to GlassApplication where you assume that [NSApp delegate]
is a GlassApplication
won't work in the case where the AWT toolkit is initialized first (e.g., a JFXPanel app).
GlassApplication* app = (GlassApplication*)[NSApp delegate]; | ||
return [app getPlatformPreferences]; |
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 think this is the cause of the crash. You cannot assume that [NSApp delegate]
is a GlassApplication
. In the case where AWT initializes the toolkit first, it won't be.
I can reproduce this locally. Any app that initializes the AWT toolkit and then uses FX will hit this, including |
It seems that there's no reliable way to retreive the |
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'll take a closer look later, but the changes to solve the problem with GlassApplication look good to me.
I'll also fire off another headful test run and report the results.
return (jlong)[[GlassApplication alloc] initWithEnv:env | ||
application:japplication | ||
launchable:jlaunchable | ||
taskbarApplication:isTaskbarApplication | ||
classLoader:classLoader]; | ||
} | ||
|
||
GlassApplication *glass = [[GlassApplication alloc] initWithEnv:env application:japplication launchable:jlaunchable taskbarApplication:isTaskbarApplication classLoader:classLoader]; | ||
/* | ||
* Class: com_sun_glass_ui_mac_MacApplication | ||
* Method: _runLoop | ||
* Signature: (J)V | ||
*/ | ||
JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacApplication__1runLoop | ||
(JNIEnv *env, jobject japplication, jlong appDelegate) | ||
{ | ||
LOG("Java_com_sun_glass_ui_mac_MacApplication__1runLoop"); | ||
|
||
NSAutoreleasePool *glasspool = [[NSAutoreleasePool alloc] init]; | ||
{ | ||
GlassApplication* glass = (GlassApplication*)appDelegate; |
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 looks like a clean split to me.
{ | ||
LOG("Java_com_sun_glass_ui_mac_MacApplication__1finishTerminating"); | ||
|
||
if (appDelegate) { | ||
[(GlassApplication*)appDelegate release]; |
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 needed because you moved the allocation of GlassApplication outside (before) the auto-release pool in runLoop, so looks good.
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.
- HelloJFXPanel does not fail anymore
- for completeness sake, ran swing/fx interop tools in the monkey tester - no problems before and after the latest changes (can't really reproduce the HelloJFXPanel use case with the MT)
- see the property events for light/dark mode and reduced data on macOS 15.1.1
Our CI headful test build passed on macOS and Linux (I'll need to run Windows manually later), so the problem is fixed (the other Robot color mismatch test failures were unrelated, and fixed by rebooting the macOS systems in question). I don't have access to Windows or Linux system where I can turn on the metering option, so I can't test if the notification works. Maybe someone else can? I'll review the code tomorrow. |
The headful test run passed on Windows. While doing manual testing of other settings (since the notification logic has changed), I discovered a reproducible crash on Windows 11:
JavaFX will crash, likely in response to the notification of a change in animation effect. |
This is a weird one. I've narrowed it down to What is strange is that at least on my machine, The quick fix in this case is simply not calling the API in question in response to the unrelated |
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 changes all look good now.
I did notice one thing in macOS while reviewing the changes in PlatformSupport.m
. The PlatformSupport object stays around after the GlassApplication is terminated via finishTerminating. It will continue to process platform events, including making Java upcalls even after the FX toolkit is stopped. You would only see this with a Swing interop app that initializes FX and then later terminates it while keeping AWT alive. I think it is preexisting, and doesn't seem to be causing any problems. It might be worth a P4 follow-up issue to investigate.
Correction: the listeners no longer get notified after the FX toolkit is stopped, perhaps due to the fix forJDK-8335630. Needs more investigation. |
This is not related to JDK-8335630. The notification does get delivered, but ends up going through the "else" block in the following code in
This happens because So I think my recommendation of "maybe file a P4 bug to look at later" is the most that is needed here. |
I've added some code that ensures that the |
I highly recommend syncing up with the latest master once the PR branch is out for a prolonged period. This will ensure that the new changes do not interfere with the latest updates, and it also saves the reviewer's time as they need to merge in order to do a good review (times N reviewers). |
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.
Looks good (macOS).
An observation: when running HelloJFXPanel
, noticed that the FX animation restarts each time the appearance preference gets changed between light and dark modes. This might be an existing issue since it can also be observed in the master branch.
I am not entirely sure this is expected, since neither the color of the animated rectangle nor the background color changes. It's unrelated to the changes in this PR (but might be related to the way the platform notifications are being processed).
Another observation related to the same animation, and also can be observed with the master branch: when one runs the HelloJFXPanel
app, the initial animation is smooth and is not affected by mouse over. Once the platform light/dark mode preference gets changed, however, the movement becomes jerky on mouse over.
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.
Looks good.
When I run it, it doesn't reset, it seems to jump -- often, but not always, to the beginning or end. In any case, it's completely unrelated to platform notifications: I just checked and it behaves the same way on JDK 8, which has no platform preference support.
I can't reproduce this on my system. If you can characterize this, please file a new bug. |
More on jerky animation: it's unrelated to the platform preferences change (which is good, for this PR anyway). It seems the jerky movement appears after HelloJFXPanel loses focus to some other window. Switch back, mouse over and the jerkiness starts. Happens even with the second external monitor disconnected. |
The
reducedData
preference instructs applications to minimize internet traffic, as users might be on a metered network or a limited data plan.This corresponds to the following OS settings:
Windows: Settings -> Network and Internet -> Ethernet/WiFi -> Metered connection
macOS: Settings -> Network -> Ethernet/WiFi -> Network Settings -> Low data mode
Ubuntu: Settings -> Network -> Wired/WiFi -> Metered connection
Change notifications work consistently on Windows and macOS. On my Ubuntu 24 system, the GIO
network-changed
signal is not sent when I only toggle the "metered connection" flag in network settings (and there's no signal specifically for low-data mode). The new value is only picked up when the connection changes by coming offline or going online./reviewers 2
/csr
Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1656/head:pull/1656
$ git checkout pull/1656
Update a local copy of the PR:
$ git checkout pull/1656
$ git pull https://git.openjdk.org/jfx.git pull/1656/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1656
View PR using the GUI difftool:
$ git pr show -t 1656
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1656.diff
Using Webrev
Link to Webrev Comment