-
Notifications
You must be signed in to change notification settings - Fork 542
8348744: Application window not always activated on macOS 15 #1685
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
8348744: Application window not always activated on macOS 15 #1685
Conversation
|
👋 Welcome back kcr! A progress list of the required criteria for merging this PR into |
|
@kevinrushforth 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 no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
|
Reviewers: @andy-goryachev-oracle @jperedadnr |
|
@kevinrushforth |
andy-goryachev-oracle
left a comment
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.
works as expected (test app stage gets focused even when the terminal window running the test script loses focus) on macOS 15.1.1 M1, running the following script:
#! /bin/bash
set -x
sleep 5
gradle --continue --info -PBUILD_TOOLS_DOWNLOAD_SCRIPT=../build-tools.gradle -PTEST_ONLY=true -PFULL_TEST=true -PUSE_ROBOT=true :systemTests:test --tests CSSRoundingTest
| LOG("-> need to active application"); | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| [NSApp performSelector: @selector(activate)]; | ||
| [NSApp activateIgnoringOtherApps:YES]; |
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 add a comment about possible removal of this API in newer platforms?
(I would suggest also include the JBS reference so the context can be obtained by the person who will be fixing this code in the future).
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 don't want to do either of these in this PR. My comment in the PR Description about possible API removal is independent of this bug and something I just happened to notice -- plus it's speculative on my part. I will file a follow-on place-holder bug for this, but there isn't anything actionable at this point. Also, I don't like the practice of putting bug IDs in for fixed bugs except in unusual cases (this isn't one of them).
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 filed JDK-8348878 to track our use of the deprecated [NSApp activateIgnoringOtherApps] method.
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.
Yes, one can typically rely on git history to make connection to the original PR/JBS. The problem is that a merge might make this information not (easily) accessible.
And yes, the comments are subject to the usual decay, when they lose the relevance (or stop being applicable), but at least one can easily find the original issue and related discussion.
Just my two yen.
| LOG("-> need to active application"); | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| [NSApp performSelector: @selector(activate)]; | ||
| [NSApp activateIgnoringOtherApps:YES]; |
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 see that the CanvasTest mentioned in the JBS issue passes now with this fix, and fails with [NSApp activate];
I'm not sure why [NSApp activateIgnoringOtherApps:YES]; works but [NSApp activate]; doesn't, given that the former is deprecated, as you already mentioned, and the latter is what Apple precisely recommends to use instead.
In any case, probably something for https://bugs.openjdk.org/browse/JDK-8348878.
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.
@jperedadnr can you add this comment to https://bugs.openjdk.org/browse/JDK-8348878 please?
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.
Done
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'm not sure why [NSApp activateIgnoringOtherApps:YES]; works but [NSApp activate]; doesn't, given that the former is deprecated, as you already mentioned, and the latter is what Apple precisely recommends to use instead.
The default activation mode is to only activate only when no other app is active, after first deactivating the launching application. This is true for the new activate method as well as the existing activateWithOptions method. [NSApp activate] is equivalent to [NSApp activateIgnoringOtherApps:NO].
The activateIgnoringOtherApps method says this:
By default, activation deactivates the calling app (assuming it was active), and then the new app is activated only if there’s no currently active application. This prevents the new app from stealing focus from the user, if the app is slow to activate and the user has switched to a different app in the interim. However, if you specify NSApplicationActivateIgnoringOtherApps, the application is activated regardless of the currently active app, potentially stealing focus from the user.
Let's continue looking into this in the context of JDK-8348878.
|
/integrate |
|
Going to push as commit f55f5c6. |
|
@kevinrushforth Pushed as commit f55f5c6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
/backport :jfx24 |
|
@kevinrushforth the backport was successfully created on the branch backport-kevinrushforth-f55f5c60-jfx24 in my personal fork of openjdk/jfx. To create a pull request with this backport targeting openjdk/jfx:jfx24, just click the following link: The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:
If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jfx: |
The fix for JDK-8319066 added a needed call to activate a JavaFX window on macOS 14 or later via
[NSApp activate]. In macOS 15, this doesn't always activate the window; even on macOS 14 there are certain cases where it might not. In all other places where we need to activate a window we call[NSApp activateIgnoringOtherApps:YES]. This is also what AWT uses in all places.The fix is to replace the call to
activatewith a call toactivateIgnoringOtherApps. I ran a full set of headful tests on macOS 15, 14, and 13 (although the code is not executed on macOS 13), and everything looks good on my end.Worth noting is that
NSApp::activateIgnoringOtherAppsis deprecated as of MacOS SDK 14, which means that we might have problems in the future when we update the Xcode toolchain (or if they eventually degrade it so that theignoringOtherAppspart of this call stops doing anything), but that will be a problem we need to address anyway, affecting other places in JavaFX and AWT.I intend to backported this fix to
jfx24after it is integrated into mainline (for 25)./reviewers 2
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1685/head:pull/1685$ git checkout pull/1685Update a local copy of the PR:
$ git checkout pull/1685$ git pull https://git.openjdk.org/jfx.git pull/1685/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1685View PR using the GUI difftool:
$ git pr show -t 1685Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1685.diff
Using Webrev
Link to Webrev Comment