FTB-App icon indicating copy to clipboard operation
FTB-App copied to clipboard

Option to set all javaw.exe in included runtime folder as High Performance under Windows Graphics settings to prevent MC from running on iGPU

Open Appulcake opened this issue 6 months ago • 4 comments

The problem

A frequently recurring issue seems to be that on PCs with an iGPU and dGPU (especially on laptop setups where by default internal panel is connected to iGPU), Minecraft (javaw.exe) runs on iGPU and isn't properly elevated to dGPU as it's not seen as an app that's high performance and would need it. This causes issues ranging from performance issues to straight up crashes depending on the iGPU.

Unfortunately, the advice to add the right javaw.exe to be ran by high performance GPU is very cumbersome and doesn't work out for a lot of people who just give up. This is mainly because there's different ways to do it, not all work at all times, and the setup is different based on OS (win 10 vs 11) and GPU (AMD/Intel/NVIDIA). NVIDIA Control Panel for example can technically do it, but it explicitly states that you should do this in Windows Graphics settings instead as that's supposed to take over this functionality. I've seen experiences where setting it in NVCP only works, or setting it in Windows only works, or where only either works, or even rare cases where it'd only work if you set it in both. I have no idea how AMD and Intel are handling it.

Furthermore, in NVCP you at least have a recently used apps list where you could find it, but this is still not obvious to a user which they need (so usual advice is to just add them all one by one and set GPU type on each) as you could see this:

Image

In the Windows Graphics settings page it's even worse as there's no recently used apps list, you just have to straight up browse to and find the right javaw.exe. Often users struggle with that too as one way is to have MC running and then find javaw.exe in task manager, hope it's the right one (some users confuse it with the java.exe process of FTB App for example), and this is assuming you can run it on the iGPU at all (in some cases, the game immediately crashes on launch when trying to run it on iGPU so you can't even use task manager to find the process).

Then on top of this, every java runtime is its own javaw.exe. A user using multiple modpacks from different MC versions would need to add javaw.exe of various folders like OpenJDK8U-jre_x64_windows_hotspot_8u312b07, OpenJDK17U-jre_x64_windows_hotspot_17.0.2_8, OpenJDK17U-jre_x64_windows_hotspot_17.0.7_7, OpenJDK17U-jre_x64_windows_hotspot_17.0.10_7, OpenJDK21U-jre_x64_windows_hotspot_21.0.3_9, OpenJDK21U-jre_x64_windows_hotspot_21.0.4_7, and possibly more. This issue is one of the more recurring problems in #java-support that has a relatively low resolution rate unfortunately because of how finicky all this is.

Proposed solution

So my proposition is to add a setting in the FTB App that adds all included JDK javaw.exe's to the Windows Graphics settings under High Performance. So what this would entail is iterating through every runtime folder in .ftba\bin\runtime where all the different JDKs are, finding the full path to each folder's javaw.exe (and also do this to any future java runtime installations), then for each full javaw.exe path add it to the following Registry key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\DirectX\UserGpuPreferences Where every entry is a String Value (REG_SZ) that's the full path (without quotes, path can be say %localappdata%.ftba [...] or just regular full path with C:\Users\User [...], both work in my tests), with the value GpuPreference=2; (0 = let windows decide, 1 = power saving, 2 = high performance). This means all these javaw.exe will be set to run under High Performance GPU (so the dGPU).

Unfortunately, I haven't found any way to make it work (nor any documentation or anyone else with it online) to accept wildcards in any way, so it can't accept say %localappdata%\.ftba to automatically have every exe in every subfolder run as high performance and prevent needing to add them all as separate entries.

Alternatives ideas

If there's any other way FTB App could help set all the bundled JDKs' javaw.exe to run as high performance / dGPU, that'd be great

Appulcake avatar Oct 04 '25 15:10 Appulcake

Somewhat related and proof of concept of a workaround solution in the meanwhile I planned on sharing with people asking for help about this in Discord is a powershell script that iterates through java runtime folders of default install paths of various launchers (FTB App, CurseForge, Prism, vanilla launcher and app variant) and adds any occurrence of a javaw.exe's full path to that registry path as a way of adding them all to run under dGPU, but I'd love a cleaner solution in the FTB App too that can manage its own JDK runtime javaw.exe's as a user setting.

Also benefit is this current user registry path means this shouldn't need admin rights to do any of this.

AddJavaw.txt (github doesn't allow uploading .ps1 so I renamed it to .txt)

Appulcake avatar Oct 04 '25 15:10 Appulcake

Thanks for the super detailed report, I'll take a look into this for you and I'll likely have some test builds at some point :)

Please ignore anything copilot does, thought it would be funny to see it try and tackle this xD

MichaelHillcox avatar Oct 04 '25 16:10 MichaelHillcox

Thank you and I'll definitely try them out on various test setups! Been talking to Lupus about this mentioning how I find it absolutely atrocious how difficult it is to set this for a regular non tech-savvy user (both adding every javaw.exe instance and how inconsistent it works between all the settings UIs), I've gone down the rabbit hole a lot to find better solutions but always fell short (closest I got is supposedly in NVCP you can set a whole folder as a profile so you could add ftba folder and then supposedly it states that'll include all exes in the folder and subfolders - so that's not correct, it ignores subfolders...).

(Yes I'm very upset at how none of Microsoft, AMD, NVIDIA, and Intel have a proper and convenient user solution for this)

This is the closest I got to some kind of user-friendly blanket solution to at least cover everyone using FTB App and using default Java settings so using the bundled runtime libraries.

The only fast and global way I've personally found to have such a profile in NVCP is to add javaw.exe as a global process without path, but you can't do this in NVCP, I managed it via NVIDIA Profile Inspector but I don't feel well recommending many random people to use such third party tools (that have a lot of power to mess things up if they click the wrong things) and on top can get reset on subsequent driver updates.

I'll get my popcorn to watch Copilot's solution!

Appulcake avatar Oct 04 '25 16:10 Appulcake

So I've been looking into this myself a bit.

From what I can tell, we basically already have a resolve for this but it's kind a pain in the ass right now. Essentially each instance can have a custom java version set in the instance settings.

The recommended solution right now would be to:

  • Go to adoptiums website and download & install each required java version for Minecraft. Currently, 8, 17, and 21. Either download the installer and note down where it installs, or download the zip and place the java files somewhere you can remember.
  • Then go to the app, install a modpack and select a one of those java versions as the java version to use for Minecraft.
  • Then go to how ever you'd normally tell the laptop which GPU to use and specify one / all of those custom java versions you've installed.
  • Profit?

This is by far not the best solution but it would appear that to do this natively would be a complete pain. I think the one thing we could 100% do from our side would be to allow the instance defaults to specifiy a java runtime folder for each java version so you don't need to change it every time you install a new modpack

MichaelHillcox avatar Nov 30 '25 22:11 MichaelHillcox