Fix command line not being restored after NeoForge early window init#3803
Conversation
Newer NeoForge creates the early GL context through the early window bootstrap path, so Sodium's normal Window#createGlfwWindow restore path does not run for that context. Wait for the early window renderer to initialize, then restore the Nvidia/AMD command line workaround using the existing undo methods.
|
Thank you for looking into this. You're using a polling approach, which makes me wonder whether there's maybe instead some place that we could hook into that would give us this event explicitly. Is that possible? |
|
afaict neoforge doesn't expose a hook for this exact point. the point we want is after
so unless we add a neoforge hook or use an early transformer/mixin into neoforge internals, polling seems like the only sodium-side option. |
|
Hi @FlashyReese, thanks for fixing the bug! I just tested it and the issue is indeed no longer happening in the PR version. We just had another user ask us on Discord if there's any update today, so it's fortuitous timing that we can now tell them that the fix is in sight. :) |
Does this mean that if we did it later at this point it wouldn't work properly? |
Probably works, just later than ideal. I will test a local patch. |
Replace polling the early window state with hooks around `takeOverGlfwWindow()`. This restores the PEB when Minecraft takes over the early window, after NeoForge has already waited for the early renderer to initialize.
|
Switched this to hook |
|
@FlashyReese, tested it, seems to no longer fix the issue, unfortunately |
|
I wonder why the timing matters here. Are other applications reading the command line args of the game at some specific early time? |
This reverts commit a37f64e.
|
my guess is that some overlay apps read/cache the process command line pretty early.
we only need the spoof until |
|
Thank you for testing it. I'll merge this soon if nobody else has any concerns. I'm not the code owner for this, so I'd like a sign of approval from somebody else if possible. |
|
Does this need to be backported to 26.1? |
|
This affects 1.21.10+ |
…3803) Newer NeoForge creates the early GL context through the early window bootstrap path, so Sodium's normal Window#createGlfwWindow restore path does not run for that context. Wait for the early window renderer to initialize, then restore the Nvidia/AMD command line workaround using the existing undo methods.
…3803) Newer NeoForge creates the early GL context through the early window bootstrap path, so Sodium's normal Window#createGlfwWindow restore path does not run for that context. Wait for the early window renderer to initialize, then restore the Nvidia/AMD command line workaround using the existing undo methods.
Fixes #3733
On newer NeoForge, Sodium applies the Nvidia/AMD command line workaround from the early window bootstrap path, but the normal
Window#createGlfwWindowrestore path is not hit for that early GL context.This leaves the spoofed command line in the PEB after startup.
This waits for NeoForge's early renderer to initialize, then restores the command line using the existing undo path. The workaround still stays active long enough for the driver to initialize, but it should no longer remain visible for the rest of the process.