Local Network Privacy Child Process Behavior

I have a Java Swing application that is bundled into an app bundle using jpackage. The app basically launches a newer version of itself, when there is a new version downloaded in the users installation directory. I have noticed a regression or change in behavior with how LocalNetwork privacy works now.

Previously, we would launch our Java application using the .app bundle. This is a launcher that checks for updates and will launch another JVM instance using any new jars it downloads when updating. So, it is closing the original process and spawning a new process using the downloaded jar. The new process is where the app connects to a server on the Local Network.

This new process cannot access the Local Network even when the entry in privacy and security is enabled for the parent process. I have changed the behavior of my launcher application so that it keeps the process alive after launching the client application. When doing this, Local Network access works.

So, my question is: is it required for the parent process to be running in order for a child process to have Local Network access? In previous macOS versions, this was not an issue, so something has changed with Local Network security across all the latest versions 26 and 27.

Answered by DTS Engineer in 915894022

So the way that a native Mac app avoids this problem is, once the update is complete, the new app is launched by NSWorkspace rather spawned as a child process. This means that the new app behaves like it’s been launched from the Finder. This avoids exercising the specific local network privacy issue that you’ve bumped into, but it also avoids a world of other edge cases as well.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

something has changed with Local Network security across all the latest versions 26 and 27

Oh, I'm sure. It's not even a good idea to talk in whole numbers anymore. You can expect significant differences between 27.0.1 and 27.2, for example.

Things like Local Network access are among the areas most likely to see changes these days.

And you're running Java. <shakes head in sympathy>

is it required for the parent process to be running in order for a child process to have Local Network access?

If that's what you're seeing, then that's the requirement, at least for today. That may change, also maybe today. But if you want to support your current OS version, then you'll have to assume this is a requirement forever.

So the way that a native Mac app avoids this problem is, once the update is complete, the new app is launched by NSWorkspace rather spawned as a child process. This means that the new app behaves like it’s been launched from the Finder. This avoids exercising the specific local network privacy issue that you’ve bumped into, but it also avoids a world of other edge cases as well.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thank you for the NSWorkspace information.

I looked into it and am not quite sure how I would create one. My app is bundled with java jpackage 17.0.19, so that launches automatically using whatever mechinism jpackage bundled to launch my launcher.jar. Once the launcher is running, and the user connects to a server, it then launches the client.jar using java's ProcessBuilder.

Would launching the launcher.jar (the original app bundle) using a wrapper program to create a NSWorkspace allow the child process (that the launcher starts) to be part of the NSWorkspace? Since the java runtime is not an app bundle, I don't think NSWorkspace can open it.

Here is a simplified example of how I launch the client.jar inside the launcher.jar.

final var command = "<path-to_bundled-jre-inside-app-bundle>/java - jar <users-home-dir>/install-dir/jars/client.jar"
 ProcessBuilder pb = new ProcessBuilder(command);
      pb.redirectError(ProcessBuilder.Redirect.appendTo(
          new File(System.getProperty("user.home") + File.separator + "vcs" + File.separator + "log" + File.separator + "launcher_error.log")));
      pb.redirectOutput(ProcessBuilder.Redirect.appendTo(
          new File(System.getProperty("user.home") + File.separator + "vcs" + File.separator + "log" + File.separator + "launcher.log")));
      pb.directory(new File(jarDir));
      try {

      // start the second JVM process
        pb.start();
      } catch (Exception e) {
        log.error("Error starting client Java process", e);
      }
      closeLoadingDialog();

      // The launcher exits after starting the client
      System.exit(0);

So I interpreted your original email as if both the old and new versions of your app were… well… apps, that it, things that users double click in the Finder. In that case your problem would be equivalent to that faced by any other (non-App Store) app, that is, how do you update your app and ensure that the new version of your app continues with the same privileges as the old one.

Clearly that’s not the case.

So, what’s the relationship between your launcher and this client app? Is client.jar actually an update to the code in launcher.jar? Or is this some sort of trampoline thing, where launcher.jar only exists to get client.jar running?

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

So, what’s the relationship between your launcher and this client app? Is client.jar actually an update to the code in launcher.jar? Or is this some sort of trampoline thing, where launcher.jar only exists to get client.jar running?

The installed macOS .app bundle essentially acts as a bootstrapper (or trampoline) that launches the latest available version of our Java launcher.

The .app bundle includes a bundled JVM and an initial version of launcher.jar. The installed .app bundle itself is never automatically updated. Updating the bundled JVM or original launcher requires reinstalling the application.

Instead, we support application updates by downloading newer versions of launcher.jar and client.jar from the server.

The startup process works as follows:
  1. When the user opens the .app, the bundled JVM starts the included launcher.jar.

  2. The bundled launcher checks whether a newer launcher.jar has previously been downloaded.

  3. If a newer version exists, the bundled launcher immediately starts it in a separate JVM process and exits.

  4. The active launcher provides the interface for entering server connection information.

  5. Once connected, the launcher checks the server for updated versions of launcher.jar and client.jar, downloading them as necessary.

  6. The launcher starts client.jar in another JVM process and then exits.

  7. If a newer launcher.jar was downloaded, it will be used the next time the .app starts.

This means we're not actually updating the installed macOS application. We're using the installed application as an entry point to execute newer Java code downloaded from the server. The reason the server provides a client.jar and launcher.jar is because the launcher allows connecting to different versions of the server. The server is deployed with client.jars that match the server version. So the launcher could connect to a server running say version 1.0.0 and another running 1.2.0, it will just download the jar and run it when connecting and loading the client.

Hopefully that explains it a little better. The process is more complex then just lauching an app.

So, from a user interface perspective, each of these shows up in the Dock as a separate app, right? So, assuming the everything-is-up-to-date case, in step 1 the launcher shows up in the Dock and in step 6 the client appears in the Dock and then the launcher disappears.

Is that right?

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes, that is correct.

The launcher shows up in the Dock, then after it launches the client, it disappears from the dock, and the client appears in the dock. They all have a similar icon so that they feel like a single application.

Thanks for the confirmation.

This approach for running your app — where the user double clicks one app, which shows in the Dock and then quickly disappears, being replaced by a different app — isn’t really something we encourage on the Mac. The expected model is:

  • The user double clicks on app and it stays running.
  • If the app wants to update itself, it does that in place, and then relaunches.

Now, there’s nothing to stop you from structuring the app the way that you’ve structured it, but it takes you off the well-trodden path and that does occasionally lead to pitfalls. Hence I’m not entirely surprised by the change you’re seeing between macOS 26 and 27, and your theory as to what’s causing it (the parent lifetime vs the child lifetime) seems reasonable enough.

But it does raise the question of what to do about it. I see three options.

First, you could file a bug about this change in behaviour.

Second, you could attempt a workaround by keeping the parent process around until the child has actually started using the network. I’m not sure if that’d actually work, but it’s worth experimenting with.

Third, you could drag your app on to macOS’s well-trodden path. That would involve packaging your app as an app and then using the standard update mechanism to update in place [1].

Finally, you could combine these approaches, for example, file a bug for a short-term fix and also making longer-term plans to adopt a more standard structure.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Annoyingly, Apple doesn’t have a standard API for this, but there is a third-party library that’s extremely popular.