Rework graphics adapter scanning to not use the Windows registry
jellysquid3 opened this issue Β· 8 comments
Minecraft 1.20.5 and later now use a newer version of OSHI, which changed the way that graphics adapters are enumerated on the system. Specifically, it now looks at the Windows registry under SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}
instead of querying WMI.
This has a number of problems:
- The information contained is often out-of-date or incorrect. The registry can contain (many) entries for GPUs that are not installed.
- The version numbers reported are inconsistent with what we expect. This causes problems like #2432 which are not obvious how to solve.
- Sometimes, the registry values (specifically the
DriverVersion
key) are not of an expected type, and trying to query it causes a crash at startup. (see #2450)
In general, it seems the registry is just completely unreliable and is nothing but a trainwreck to interact with. And tragically, this would be typical for anything on Windows.
There is now a new graphics adapter probe implementation using D3D-KMT on Windows. This should fix the problems described in the issue...
Fixed with 4041519...b1164fb.
We should either revert to using the WMI interface (which is non-trivial, because we'd need to copy a lot of code that interacts with Win32/COM), or we need to find some other way to query the driver information which does not rely on the registry.
We also need to patch Minecraft itself to no longer use the (broken) method, since it tries to enumerate the graphics adapters in the system when producing the crash report, and can fail/abort if that doesn't work.
Regarding the point about the registry keys not getting cleaned up, we've seen ridiculous reports like the following...
If you don't fully remove your graphics drivers before installing a different GPU, nothing ever gets invoked to clean up the old registry entries, and then Sodium gets confused because it sees a bunch of GPUs that are not even installed.