RFR: 8315657: Application window not activated in macOS 14 Sonoma

Florian Kirmaier fkirmaier at openjdk.org
Fri Sep 22 14:24:39 UTC 2023


On Thu, 21 Sep 2023 19:10:38 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

> The fix for [JDK-8233678](https://bugs.openjdk.org/browse/JDK-8233678) added a step to the NSApplication initialization to deactivate and then reactivate the application. We trigger the deactivation the first time applicationDidBecomeActive is called. We then trigger the reactivation the when applicationDidResignActive is called after that. The initialization logic in MacApplication spins up a nested event loop that waits for the reactivation (a second call to applicationDidBecomeActive).
> 
> Something in macOS 14 has changed that prevents the initial call to applicationDidBecomeActive from being done until the application has finished launching (notifyDidFinishLaunching).
> 
> So the activation of the NSApplication is waiting for the launching to be finished, but the nested event loop we spin up is blocking the completion of launching until we get the activation. This is a classic deadlock.
> 
> The good news, though, is the deactivation / reactivation of the application no longer seems to be needed on macOS 14. The menus work fine without that fix.
> 
> The proposed solution is to check the version of macOS and only enable the deactivation / reactivation logic on systems prior to macOS 14. This will have the additional benefit of avoiding the brief flash when the app is first launched (see [JDK-8257835](https://bugs.openjdk.org/browse/JDK-8257835)).
> 
> This is a Draft PR with a few debugging statements. Once I get some feedback that it works for more than just me, I'll remove the debugging statements and then make it "rfr".

Because I updated my Laptop to Sonoma (so I find bugs earlier) - I was able to test it!

With this branch,
I no longer get the following warning:


[error] Sep 22, 2023 3:12:18 PM com.sun.glass.ui.mac.MacApplication lambda$waitForReactivation$6
[error] WARNING: Timeout while waiting for app reactivation
``` 

And the mysterious (did anyone notice?) 5 Seconds freeze before showing the App is also gone!

So, I can confirm this fixes these important Sonoma bugs!

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1247#issuecomment-1731439919


More information about the openjfx-dev mailing list