Merge pull request #20 from ludovic111/client-platform-jvm
Apply official platform JVM flags in the standalone client launcher
This commit is contained in:
@@ -135,7 +135,7 @@ python3 tools/build_mod.py
|
||||
python3 tools/build_release.py
|
||||
```
|
||||
|
||||
Gitignored `dist/` contains fourteen packs, our original instrumentation JAR, client/server starter ZIPs and SHA256SUMS. [mods.lock.json](packs/mods.lock.json) pins mod versions, exact dependency closure, SHA-1/SHA-512 and source/license; [fabric.lock.json](packs/fabric.lock.json) pins loader/library SHA-256. Packs use the [Modrinth format](https://support.modrinth.com/en/articles/8802351-modrinth-modpack-format-mrpack). They embed only original project code; third-party mods, game and assets download from their publishers.
|
||||
Gitignored `dist/` contains nineteen packs, our original instrumentation JAR, client/server starter ZIPs and SHA256SUMS. [mods.lock.json](packs/mods.lock.json) pins mod versions, exact dependency closure, SHA-1/SHA-512 and source/license; [fabric.lock.json](packs/fabric.lock.json) pins loader/library SHA-256. Packs use the [Modrinth format](https://support.modrinth.com/en/articles/8802351-modrinth-modpack-format-mrpack). They embed only original project code; third-party mods, game and assets download from their publishers.
|
||||
|
||||
The server starter uses Lithium/FerriteCore and `/horizonserver bench <label> <seconds>`. [Server instructions](docs/server-quickstart.txt) cover setup and a baseline. Files are prepared before you accept Minecraft's EULA locally. A 50-active-player workload remains to be measured.
|
||||
|
||||
@@ -146,6 +146,11 @@ python3 tools/build_pack.py --profile m2-balanced --instance .local/runtime/m2-b
|
||||
vscreen run python3 tools/runtime.py demo --instance .local/runtime/m2-balanced
|
||||
```
|
||||
|
||||
The standalone demo launcher applies the pinned official manifest's conditional
|
||||
JVM flags, including macOS `-XstartOnFirstThread` and the Windows heap-dump-path
|
||||
option. Prism applies its own official manifest. Server JVM policy is separate;
|
||||
this launcher correction is not a measured graphics performance improvement.
|
||||
|
||||
## Local game inspection
|
||||
|
||||
Game JARs, decompiled Java, libraries, inventories, worlds and logs live **inside this checkout** under gitignored **`.local/`**. No game code is in Git history or release downloads. Fresh clones regenerate the inspection workspace from official downloads; Microsoft credentials are not needed for this step.
|
||||
|
||||
@@ -179,6 +179,52 @@ class PackTests(unittest.TestCase):
|
||||
self.assertFalse(runtime.library_allowed(library, "linux", "aarch64"))
|
||||
self.assertFalse(runtime.library_allowed(library, "osx", "x86_64"))
|
||||
|
||||
def test_conditional_client_jvm_arguments_follow_official_platform_rules(self):
|
||||
windows = "-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump"
|
||||
manifest = {"arguments": {"jvm": [
|
||||
{"rules": [{"action": "allow", "os": {"name": "osx"}}], "value": ["-XstartOnFirstThread"]},
|
||||
{"rules": [{"action": "allow", "os": {"name": "windows"}}], "value": windows},
|
||||
{"rules": [{"action": "allow", "os": {"arch": "x86"}}], "value": "-Xss1M"},
|
||||
"-cp", "${classpath}", "--enable-native-access=ALL-UNNAMED",
|
||||
]}}
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "osx", "aarch64"), ["-XstartOnFirstThread"])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "osx", "x86_64"), ["-XstartOnFirstThread"])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "windows", "AMD64"), [windows])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "windows", "arm64"), [windows])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "linux", "x86_64"), [])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "windows", "x86"), [windows, "-Xss1M"])
|
||||
# Client platform flags must not leak into the shared server JVM policy.
|
||||
self.assertEqual(runtime.jvm_options("3G", True, "g1"),
|
||||
["-Xms512M", "-Xmx3G", "-XX:+UseCompactObjectHeaders", "-XX:+UseG1GC"])
|
||||
|
||||
def test_conditional_client_jvm_arguments_observe_rule_order_and_reject_placeholders(self):
|
||||
argument = {"rules": [{"action": "allow", "os": {"name": "osx"}},
|
||||
{"action": "disallow", "os": {"arch": "x86_64"}}], "value": "-XstartOnFirstThread"}
|
||||
manifest = {"arguments": {"jvm": [argument]}}
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "osx", "aarch64"), ["-XstartOnFirstThread"])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options(manifest, "osx", "x86_64"), [])
|
||||
self.assertEqual(runtime.conditional_client_jvm_options({}, "linux", "x86_64"), [])
|
||||
argument["value"] = "${unsupported}"
|
||||
with self.assertRaisesRegex(ValueError, "Unsupported"):
|
||||
runtime.conditional_client_jvm_options(manifest, "osx", "aarch64")
|
||||
|
||||
def test_demo_command_includes_mac_first_thread_flag_before_main_class(self):
|
||||
manifest = {"id": "26.3", "assetIndex": {"id": "fixture"}, "arguments": {"jvm": [
|
||||
{"rules": [{"action": "allow", "os": {"name": "osx"}}], "value": "-XstartOnFirstThread"}]}}
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
root = Path(temp)
|
||||
with mock.patch.object(runtime, "prepare_client", return_value=(manifest, [root / "game.jar"], root / "natives")), \
|
||||
mock.patch.object(runtime.platform, "system", return_value="Darwin"), \
|
||||
mock.patch.object(runtime.subprocess, "run") as run, \
|
||||
mock.patch("sys.argv", ["runtime.py", "demo", "--instance", str(root / "instance")]):
|
||||
runtime.main()
|
||||
command = run.call_args.args[0]
|
||||
self.assertEqual(command.count("-XstartOnFirstThread"), 1)
|
||||
self.assertLess(command.index("-XstartOnFirstThread"),
|
||||
command.index("net.fabricmc.loader.impl.launch.knot.KnotClient"))
|
||||
self.assertEqual(command.count("-cp"), 1)
|
||||
self.assertTrue(run.call_args.kwargs["check"])
|
||||
|
||||
def test_native_architecture_is_selected_even_with_os_only_rules(self):
|
||||
intel = {"name": "org.lwjgl:lwjgl:3.4.3:natives-macos"}
|
||||
arm = {"name": "org.lwjgl:lwjgl:3.4.3:natives-macos-arm64"}
|
||||
|
||||
@@ -91,6 +91,20 @@ def library_allowed(library, system=None, architecture=None):
|
||||
return allowed
|
||||
|
||||
|
||||
def conditional_client_jvm_options(manifest, system=None, architecture=None):
|
||||
"""Use official OS/architecture flags alongside our managed JVM/classpath options."""
|
||||
options = []
|
||||
for argument in manifest.get("arguments", {}).get("jvm", []):
|
||||
if not isinstance(argument, dict) or not library_allowed(argument, system, architecture):
|
||||
continue
|
||||
value = argument["value"]
|
||||
values = [value] if isinstance(value, str) else value
|
||||
if not isinstance(values, list) or any(not isinstance(item, str) or "${" in item for item in values):
|
||||
raise ValueError("Unsupported conditional client JVM argument")
|
||||
options.extend(values)
|
||||
return options
|
||||
|
||||
|
||||
def native_library_matches(library, architecture=None):
|
||||
"""Modern manifests list both x64 and ARM natives with OS-only rules."""
|
||||
architecture = (architecture or platform.machine()).lower()
|
||||
@@ -157,6 +171,7 @@ def main():
|
||||
instance = args.instance.resolve()
|
||||
instance.mkdir(parents=True, exist_ok=True)
|
||||
command = ["java", *jvm_options(args.heap, args.compact_headers, args.gc),
|
||||
*conditional_client_jvm_options(manifest),
|
||||
"--enable-native-access=ALL-UNNAMED",
|
||||
f"-Djava.library.path={natives}", f"-Dorg.lwjgl.system.SharedLibraryExtractPath={natives}",
|
||||
"-Dfabric.log.disableAnsi=true", "-cp", os.pathsep.join(map(str, jars)),
|
||||
|
||||
Reference in New Issue
Block a user