Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8319066

Application window not always activated in macOS 14 Sonoma

    XMLWordPrintable

Details

    Backports

      Description

        The fix for https://bugs.openjdk.org/browse/JDK-8315657 solved the issue of JavaFX applications staying in the background after they were launched.

        After that fix, and on macOS 14.0+, when apps are created via jpackage, launching them from their shortcut icon works fine, as they get to the foreground and are properly activated.

        However, when they are launched from the command line, they get to the foreground but they are not activated, and the user needs to click on them for that, otherwise, the activated application is still the Terminal (or IDE) app from they were launched.

        For a quick test, install SceneBuilder with JavaFX 21.0.1 (from https://github.com/gluonhq/scenebuilder/releases/download/21.0.1-RC/SceneBuilder-21.0.1-RC-aarch64.dmg or https://github.com/gluonhq/scenebuilder/releases/download/21.0.1-RC/SceneBuilder-21.0.1-RC-amd64.dmg).

        Launch SceneBuilder from the shortcut icon:
        (from shortcut.png)

        Launching SceneBuilder from command line with:
        $ /Applications/SceneBuilder.app/Contents/MacOS/SceneBuilder
        (from commandline.png)

        This can also be reproduced easily launching any JavaFX application from command line:
        java --module-path ... --add-modules javafx.controls myApp
        mvn javafx:run
        gradle run
        ...

        With some debugging, it can be seen that the launching process stops at applicationDidFinishLaunching:

         [main:0] Java_com_sun_glass_ui_mac_MacApplication__1initIDs
         [main:0] Java_com_sun_glass_ui_mac_MacApplication__1runLoop
         [main:0] waiting for [glass started]
         [main:1] GlassApplication:runLoop ENTER
         [main:0] waiting for [glass started]
         [main:0] waiting for [glass started]
         [main:0] waiting for [glass started]
         [main:1] GlassApplication:applicationWillFinishLaunching
         [main:1] Java_com_sun_glass_ui_mac_MacApplication__1isTriggerReactivation
         [main:1] Java_com_sun_glass_ui_mac_MacApplication__1getScreens
         [main:1] Java_com_sun_glass_ui_mac_MacApplication__1getVideoRefreshPeriod
         [main:1] CVDisplayLinkGetActualOutputVideoRefreshPeriod: 0.016667
         [main:1] GlassApplication:application:openFiles
         [main:1] GlassApplication:applicationDidFinishLaunching

        so these are missing:
        [main:1] GlassApplication:applicationWillBecomeActive
        [main:1] GlassApplication:applicationDidBecomeActive

        Attachments

          Issue Links

            Activity

              People

                jpereda Jose Pereda
                jpereda Jose Pereda
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: