neoforged / ModDevGradle

A Gradle plugin for developing Minecraft mods using NeoForge
https://projects.neoforged.net/neoforged/moddevgradle
GNU Lesser General Public License v2.1
33 stars 4 forks source link

-XstartOnFirstThread JVM argument is not correctly set on MacOS #50

Closed Trikzon closed 3 months ago

Trikzon commented 3 months ago

On MacOS, -XstartOnFirstThread needs to be added as a JVM argument to the generated run configurations. Without it, the following error happens when running the game and the game fails to load.

Exception in thread "main" java.lang.IllegalStateException: GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.
    at MC-BOOTSTRAP/org.lwjgl.glfw@3.3.3+5/org.lwjgl.glfw.EventLoop.check(EventLoop.java:33)
    at MC-BOOTSTRAP/org.lwjgl.glfw@3.3.3+5/org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1078)
    at MC-BOOTSTRAP/fml_earlydisplay@4.0.6/net.neoforged.fml.earlydisplay.DisplayWindow.initWindow(DisplayWindow.java:347)
    at MC-BOOTSTRAP/fml_earlydisplay@4.0.6/net.neoforged.fml.earlydisplay.DisplayWindow.start(DisplayWindow.java:290)
    at MC-BOOTSTRAP/fml_earlydisplay@4.0.6/net.neoforged.fml.earlydisplay.DisplayWindow.initialize(DisplayWindow.java:153)
    at MC-BOOTSTRAP/fml_loader@4.0.6/net.neoforged.fml.loading.ImmediateWindowHandler.load(ImmediateWindowHandler.java:71)
    at MC-BOOTSTRAP/fml_loader@4.0.6/net.neoforged.fml.loading.ModDirTransformerDiscoverer.earlyInitialization(ModDirTransformerDiscoverer.java:42)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.TransformationServicesHandler.lambda$discoverServices$17(TransformationServicesHandler.java:125)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.TransformationServicesHandler.discoverServices(TransformationServicesHandler.java:125)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:83)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:74)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
    at MC-BOOTSTRAP/cpw.mods.modlauncher@11.0.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
    at cpw.mods.bootstraplauncher@2.0.2/cpw.mods.bootstraplauncher.BootstrapLauncher.run(BootstrapLauncher.java:210)
    at cpw.mods.bootstraplauncher@2.0.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:69)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at DevLaunch@1.0.0/net.neoforged.devlaunch.Main.main(Main.java:54)

I believe that this option can be fetched automatically with getPlatformJvmArgs() to be added to the jvm argument list. Here getPlatformJvmArgs() is used by NeoGradle.

Thankfully I can just manually add the argument to my run config, so this isn't very high priority

shartte commented 3 months ago

It's high priority in that we'll fix it today ;-)

shartte commented 3 months ago

Today in... the time zone of .... 48 hours!

Trikzon commented 3 months ago

Thank you, time traveler