Keep the browse fix from aborting headless runs - #4
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Flatpak packaging and launch paths so the browse-fix Java agent no longer aborts headless runs, while still applying the agent for GUI launches where it’s needed. It also moves the agent from a prebuilt binary to a build-time-compiled artifact and improves launcher accessibility from outside the sandbox.
Changes:
- Add a unified
netlogo-launcher.shthat routes to GUI vs. headless entrypoints (and 2D vs. 3D) based on args and display availability. - Build
browse-fix.jarduring the Flatpak build using the OpenJDK 17 SDK extension, and reference it via jpackage’s$APPDIRto avoid fatal absolute-path failures. - Rename
NEWS.md→CHANGELOG.md(and update metadata), plus small documentation/spellchecker updates.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds a user-facing shell alias example for easier NetLogo access via Flatpak. |
| NEWS.md | Removes the old release notes file (replaced by CHANGELOG.md). |
| CHANGELOG.md | Introduces a Keep-a-Changelog-style changelog including the changes in this PR. |
| codemeta.json | Updates releaseNotes URL to point to CHANGELOG.md. |
| flatpak/com.danielvartan.logopak.yaml | Builds the agent at build time, attaches it via $APPDIR, adds launcher routing + JAVA_HOME/java exposure, and adds a BehaviorSearch headless command. |
| flatpak/netlogo-launcher.sh | New launcher that selects GUI vs. batch launcher and 2D vs. 3D behavior. |
| flatpak/BrowseFix.java | Skips patching when java.awt.headless=true to avoid unnecessary work in batch runs. |
| flatpak/.gitignore | Ignores locally built agent artifacts. |
| .vscode/settings.json | Updates cSpell dictionary for new terminology. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Owner
Author
|
Ok. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The browse fix agent was attached to every jpackage launcher with an absolute path:
A
-javaagentthat the JVM cannot open is fatal at VM init, so any launch where that exact path does not resolve dies before NetLogo starts:On top of that,
browse-fix.jarwas a prebuilt binary committed to the repository, so what shipped depended on the file surviving checkout, CI, and bundling intact, with no check at build time. Headless runs paid for a fix they never needed, since a batch JVM has no EDT and never opens a browser.Two smaller problems surfaced along the way. The runtime exports
JAVA_HOME=/usr/lib/jvm/java-21-openjdk, which does not exist inside the sandbox, sonetlogo-headless.sh,netlogo-gui.sh, andbehaviorsearch_headless.shall failed withNo such file or directory. And there was no way to reach those launchers from outside the sandbox anyway, since only the jpackage binaries were symlinked into/app/bin.Changes
-javaagent:$APPDIR/browse-fix.jar. jpackage expands$APPDIRto the reallib/appat launch, so the option stays valid wherever the app image is mounted: installed app,flatpak-builderbuild directory,flatpak buildshell, or bundle.org.freedesktop.Sdk.Extension.openjdk17, the same JDK version NetLogo bundles, andjar --listruns right after as a smoke test. A jar the JVM cannot read now fails the build instead of shipping.flatpak/browse-fix.jaris gone from version control.NetLogo,netlogo,NetLogo3D, andnetlogo3dpoint at a newnetlogo-launcher.sh, which picks the entry point.--headlessanywhere in the arguments, or a session with neitherDISPLAYnorWAYLAND_DISPLAY, goes tonetlogo-headless.sh, a plain JVM with no agent. Anything else goes to the jpackage launcher, which keeps the agent, the natives path, and the rest of the packaged JVM options. The script reads its own name to decide 2D against 3D, and supplies--3Donly when the caller did not.--env=JAVA_HOME=/app/opt/netlogo/lib/runtimeinfinish-args, plus ajavacommand symlinked to the bundled runtime, so NetLogo's shell launchers and any script pointed at them find a JVM.behaviorsearch-headlesscommand, since BehaviorSearch's CLI has no--headlessflag to switch on.BrowseFix.premainreturns immediately whenjava.awt.headless=true, so no polling thread is spawned in batch runs.Testing
Rebuilt and reinstalled the Flatpak, then ran, all exiting 0:
flatpak run com.danielvartan.logopak --headless --model ... --experiment ... --table ..., with a display present.--command=netlogoin a stripped environment with no display, exercising the display check.--command=netlogo3d --headlesson a.nlogox3dmodel, both with and without an explicit--3D.--command=netlogo --headless --3Don a 3D model, the 2D command name honoring an explicit flag.--command=behaviorsearch-headless, which prints its usage.The successful headless runs are themselves proof that
$APPDIRresolves, since an unresolvable agent path aborts the VM. A Swing probe inside the sandbox reportsBROWSE=falsewithout the agent andBROWSE=truewith it, so the original browser fix still works, and the GUI starts with no VM init error.Notes
NetLogonow prints NetLogo's batch usage message instead of an X connection error. Sessions with X forwarding setDISPLAY, so they still open the GUI.openjdk17SDK extension. The Flathub CI image installs dependencies from Flathub, so the workflow should pick it up, but it is worth watching on the next run.