neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://neoforged.net
Other
1.24k stars 179 forks source link

Early Display Error results in MANY bash terminals opening until I kill Minecraft #1235

Open NovaViper opened 4 months ago

NovaViper commented 4 months ago

OS

 - system: `"x86_64-linux"`
 - host os: `Linux 6.9.7-xanmod1, NixOS, 24.11 (Vicuna), 24.11.20240703.88f3dab`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.22.2`
 - nixpkgs: `/nix/store/3lp5war0iadjn9v2rr1jqbdn27pc9ix6-source`

Minecraft Launcher: PrismLauncher v8.4

Minecraft Version: 1.20.6

NeoForge Version: 20.6.119

Logs: https://mclo.gs/Oj15Q96

Steps to Reproduce:

  1. Load in a mod that causes early loading issues, such as the case specified below
  2. Create an instance of Minecraft 1.20.6 and NeoForge 20.6.119
  3. Launch the game
  4. The crash proceeds

Description of issue: When I launch the app with a mod that seems to break the early loading process (I was doing some testing with a handful of mods, which I got all from Modnrith); the game crashes but then I suddenly get spammed with a new sh process saying the message below almost every second until I just manage to kill the game forcibly. Earlier when it happened in 1.21, it actually ended up crashing my computer because so many bash processes opened that it literally ate up 32GB of my system's ram 👀

Minecraft: NeoForge

Failed to initialize the mod loading system and display.

Failure details:
We seem to be having trouble handing off the window, tried for 1 second

If you click yes, we will try and open https://links.neoforged.net/early-display-errors in your default browser
y/n: 
sciwhiz12 commented 4 months ago

Seems to be a bug in FancyModLoader's early display window, yes.

The early display window has code to 'elegantly crash' by displaying a window to the user (using TinyFileDialogs), and optionally open the browser to the early display errors short link before closing the browser. This is intentional, in order to better inform the user of the crash instead of just a silent close with only the logs as evidence.

The problem here is twofold:

  1. The loop for acquiring the render lock ticket calls that elegant crash method for every 10 failed acquisitions of the render lock.

  2. The elegant crash method does not block on invocation, but instead offloads showing the screen to a separate thread and allows the original thread to continue invocation.

Because of these two problems, and assuming the lock acquisition fails every time, until the user acts on one of those windows (in order to progress the crash window thread to the System.exit line), FML will keep opening the error window every second or so.

Ideally, the elegant crash method should block on invocation, or the lock acquisition loop should stop retrying after the first 10 tries and spin-lock (to wait on the crash window thread to System.exit it out of its misery).

NovaViper commented 4 months ago

Ah that explains alot! Also wanted to mention that the bug also occurs on 1.21 with NeoForge v21.0.52-beta, same exact message on the screen too

shartte commented 4 months ago

@sciwhiz12 Do we backport this?

sciwhiz12 commented 4 months ago

@sciwhiz12 Do we backport this?

If someone's willing to put the work in. We always target the latest version first though.

shartte commented 4 months ago

The problem will be finding the right FML version to branch off of. I would also only do it for 1.20.4