
Incompatibility with LibGui
CofiPRT opened this issue ยท 0 comments
I was investigating an issue where using LibGui (or any mod that includes it) together with OptiFabric leads to a game crash on startup.
OptiFabric version: 1.13.24
Fabric API version: 0.80.0+1.19.4
LibGui versions: 7.0.1+1.19.4
, 7.1.0+1.19.4
, 7.1.1+1.19.4
This is what the stack trace look like
Caused by: java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "resourceName" is null
at net.minecraft.class_2960.method_12830(class_2960.java:88) ~[client-intermediary.jar:?]
at net.minecraft.class_2960.<init>(class_2960.java:51) ~[client-intermediary.jar:?]
at net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram.rewriteAsId(FabricShaderProgram.java:42) ~[fabric-rendering-v1-2.1.2+504944c8f4-d3f123cd32cf48f7.jar:?]
> at net.minecraft.class_5944.modify$zng000$fabric-rendering-v1$modifyProgramId(class_5944.java:654) ~[client-intermediary.jar:?]
> at net.minecraft.class_5944.localvar$bfj000$optifabric$modifyProgramID(class_5944.java:1634) ~[client-intermediary.jar:?]
at net.minecraft.class_5944.<init>(class_5944.java:114) ~[client-intermediary.jar:?]
at net.minecraft.class_5944.<init>(class_5944.java:108) ~[client-intermediary.jar:?]
at net.fabricmc.fabric.impl.client.rendering.FabricShaderProgram.<init>(FabricShaderProgram.java:28) ~[fabric-rendering-v1-2.1.2+504944c8f4-d3f123cd32cf48f7.jar:?]
at net.minecraft.class_757.md001ae3$fabric-rendering-v1$lambda$registerShaders$0$0(class_757.java:2627) ~[client-intermediary.jar:?]
at io.github.cottonmc.cotton.gui.impl.client.LibGuiShaders.lambda$register$1(LibGuiShaders.java:18) ~[libgui-7.0.1+1.19.4-38026f7114167cd3.jar:?]
at net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallback.lambda$static$0(CoreShaderRegistrationCallback.java:44) ~[fabric-rendering-v1-2.1.2+504944c8f4-d3f123cd32cf48f7.jar:?]
at net.minecraft.class_757.handler$zne000$fabric-rendering-v1$registerShaders(class_757.java:2630) ~[client-intermediary.jar:?]
at net.minecraft.class_757.method_34538(class_757.java:536) ~[client-intermediary.jar:?]
at net.minecraft.class_757$1.method_45777(class_757.java:460) ~[client-intermediary.jar:?]
at net.minecraft.class_757$1.method_18788(class_757.java:432) ~[client-intermediary.jar:?]
at net.minecraft.class_4080.method_18790(class_4080.java:13) ~[client-intermediary.jar:?]
at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?]
... 20 more
I have marked some interesting methods with >
above.
I notice that OptiFabric is making use of ShaderProgramMixin
over here.
It is using a method from the Fabric API. Notice the usage of the FabricShaderProgram::rewriteAsId
method. If we follow the flow from this point onward, I would deduce that the name
field in the previous link ends up being null
, for reasons I didn't yet manage to understand, and this is the cause of the exception.
The flow prior to this seems to be the following:
LibGui
wants to register a new shader, so thisregisterShaders
injection gets called, where a new instance ofFabricShaderProgram
is created.class_5944
is, supposedly, theShaderProgram
class but here's where I start to get a bit lost because I don't understand why there are two calls to its constructor in the stack trace
at net.minecraft.class_5944.<init>(class_5944.java:114) ~[client-intermediary.jar:?]
at net.minecraft.class_5944.<init>(class_5944.java:108) ~[client-intermediary.jar:?]
I would guess there are two different constructors, but in the sources that I'm checking I can only see one constructor
- Then, according to the stack trace, the OptiFabric mixin gets triggered, and I am confused again because I don't see a call to
Identifier::getNamespace
in the sources that I'm checking. I don't quite understand the type of interception that happens, but my guess is that: this Fabric Mixin gets triggered insideShaderProgram
's constructor, and with that, it is intercepted byOptiFabric
And of course, after this interception happens, the flow continues and it happens that Fabric's ShaderProgramMixin::name
field ends up null
, and provoking the crash.
I am presenting this analysis because I don't know how to continue it in order to work toward a fix, and at the same time I want to add a somewhat off-topic question:
Based on OptiFabric's README.md, what should the dependency look like in order to make use of, let's say, the 1.13.24
version of OptiFabric?