CaffeineMC / sodium-fabric

A Minecraft mod designed to improve frame rates and reduce micro-stutter
Other
4.71k stars 804 forks source link

Crash when a graphics adapter is present which does not support OpenGL #2591

Closed D2Lx0wse closed 3 weeks ago

D2Lx0wse commented 2 months ago

Bug Description

The game crashes with this error A mod crashed on startup! net.fabricmc.loader.impl.FormattedException: java.lang.RuntimeException: Could not execute entrypoint stage 'preLaunch' due to errors, provided by 'sodium'! at net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:63) at net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:162) at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:68) at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23) at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100) at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) at org.prismlauncher.EntryPoint.main(EntryPoint.java:70) Caused by: java.lang.RuntimeException: Could not execute entrypoint stage 'preLaunch' due to errors, provided by 'sodium'! at net.fabricmc.loader.impl.FabricLoaderImpl.lambda$invokeEntrypoints$2(FabricLoaderImpl.java:388) at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33) at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:386) at net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:160) ... 5 more Caused by: java.lang.NullPointerException: Cannot invoke "String.matches(String)" because "driverName" is null at me.jellysquid.mods.sodium.client.compatibility.checks.PreLaunchChecks.findIntelDriverMatchingBug899(PreLaunchChecks.java:123) at me.jellysquid.mods.sodium.client.compatibility.checks.PreLaunchChecks.onGameInit(PreLaunchChecks.java:60) at me.jellysquid.mods.sodium.client.SodiumPreLaunch.onPreLaunch(SodiumPreLaunch.java:13) at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:384) ... 6 more

Reproduction Steps

  1. Download ARM64 Prism Launcher and a ARM64 build of java 21 on a snapdragon pc
  2. Install minecraft 1.21 with fabric and the attached mods image

image

  1. Launch the game
  2. Fabric crashes

Log File

latest.log

Crash Report

The game does not produce a crash report, or gets to the main menu. Here's my specs?!?!? image image the opengl is not the best but it say it's compatible

jellysquid3 commented 2 months ago

Are you not using the latest version of Sodium? Please upload the entire log file, not the snippet. It has critical information.

jellysquid3 commented 2 months ago

We do not have anyone on our team who has access to these recent laptops with Qualcomm's Snapdragon chips. It will be impossible for anyone to debug this without the information that our issue template asks for.

D2Lx0wse commented 2 months ago

This is not a X elite laptop, as you can see in the specs, it's from 2022, also minecraft only produced the log I attached as file as it crashed so early, I tried to send all info I could

D2Lx0wse commented 2 months ago

image

jellysquid3 commented 2 months ago

Sorry. The email that was sent to me about your issue did not include the link to the log file for some reason.

jellysquid3 commented 2 months ago
[19:14:16] [main/INFO]: Found graphics adapter: AdapterInfo{vendor=UNKNOWN, description='Adreno 680', adapterType=0x0000230B, openglIcdFilePath='null', openglIcdVersion=null}

Do the Adreno drivers actually support OpenGL? It seems like they don't, and Windows is using a translation layer on top of it (OpenGL on D3D12, probably), which confuses Sodium...

jellysquid3 commented 2 months ago

I think the graphics adapter probe in Sodium is just bugged, and it doesn't account for the possibility that a GPU may not actually support OpenGL.

Marking these fields as @Nullable and then adding null-checks where the fields are accessed would likely be enough.

D2Lx0wse commented 2 months ago

I have no idea, if sodium checked if the driver name string was null image (since thats where it's erroring) could it launch? I acknowledge it'd possibly be broken cause no translation layer- oh you said it as I was typing

ading2210 commented 1 month ago

I can confirm that this issue also occurs on the new Qualcomm Snapdragon X Elite (X1E78100) systems. image

Here are my system specs: image

ading2210 commented 1 month ago

Also, it appears that OpenGL does work, since vanilla 1.21 runs just fine. It appears to be using Mesa for the OpenGL translation layer as well.

image

asumagic commented 1 month ago

Is there a chance that the translation layers belong in a different "virtual" adapter? I'm curious how the full virtual adapter list looks like, null exception aside. Otherwise, is there really no way to poll information on GLon12 support for the given platform?

FWIW, internally, on context creation, it does seem to make a difference between a native OpenGL driver and GLon12: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3dkmthk/ne-d3dkmthk-_d3dkmt_clienthint
(Although this specific hint enum seems irrelevant for sodium.)

ading2210 commented 1 month ago

I built the latest version of the mod using Intellij, and it somehow isn't crashing? The driverName is detected correctly here, but launching the game through PrismLauncher still crashes.

image

Regardless of this weird behavior, I believe it can be fixed easily by just checking if driverName is null, and continuing the loop if it is. The function that it's crashing in seems to only be for detecting Intel drivers, so this shouldn't break any existing behavior.

jellysquid3 commented 1 month ago

I'm nominating this issue for critical prioritization so that we can make a backport exception for older versions.

jellysquid3 commented 1 month ago

The mod crashing on new hardware platforms is not acceptable for me and this problem is likely manifesting elsewhere with drivers that don't actually support OpenGL natively.

jellysquid3 commented 1 month ago

If you run into this issue, you can add the following entry to your JVM arguments:

-Dsodium.checks.issue899=false

This disables the broken pre-launch check and allows the game to launch (somewhat) normally.