sp614x / optifine

1.81k stars 418 forks source link

[Crash+Bug] Optifine crashes between Nether/Overworld on AMD graphics #4558

Open coraunderhill opened 4 years ago

coraunderhill commented 4 years ago

Description of Issue

If the player character uses a portal to enter the Nether using Optifine, upon attempting to exit back through the portal to the Overworld Minecraft will immediately crash and display an error dialog.

Steps to Reproduce

  1. Open Minecraft using the Optifine installation from the launcher
  2. Enable a shader and enter the Nether
  3. Step into the portal to the Overworld
  4. Game crash

OptiFine Version

OptiFine 1.16.1 HD U G2

Installation Method

Standalone installer

Log Files/Crash Reports

hs_err_pid10260.log

F3 Debug Screenshot

116771301_736286007207176_4649239200262386721_n

Prior Testing

Additional Information

Our testing used BSL Shaders

dylanclement commented 4 years ago

Similar happening on my Radeon RX 570, although game doesn't crash, just loads a in a skybox.

R93950X commented 4 years ago

This happens to me (another AMD user) but only when I use shaders.

bscout9956 commented 4 years ago

Similar issue with me on NVIDIA, #4549 @sp614x major bug here hope you don't mind the "ping"

coraunderhill commented 4 years ago

Confirmed issue is specific to which shaderpack is active. SEUS Renewed and Sildur's work fine, while BSL crashes going to the Overworld and projectLuma crashes going into the Nether.

chaosophy commented 4 years ago

Similar issues here with an AMD Vega 64 / i7 3770K.

Game can crash with shaders, in the following scenarios ... . Enabling shaders, . Switching shaders, . Changing settings on enabled shader, . Moving between dimensions using portals.

MC 1.16.2 OptiFine_1.16.2_HD_U_G3 Various Java versions, inc the one supplied with the MC install. Win 10, latest updates. Latest AMD driver, currently 20.8.3

Happy to supply more info if needed, crash logs etc.

Thanks.

rasberryrabbit commented 4 years ago

With Builder's QOL Shader, it still crashes.


Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [atio6axx.dll+0xb6edf1]
C  [atio6axx.dll+0xb6db6b]
C  [atio6axx.dll+0xd7b207]
C  0x0000000002b35894

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.opengl.ARBShaderObjects.nglShaderSourceARB(IIJJ)V+0
j  org.lwjgl.opengl.ARBShaderObjects.glShaderSourceARB(ILjava/lang/CharSequence;)V+38
j  net.optifine.shaders.Shaders.createFragShader(Lnet/optifine/shaders/Program;Ljava/lang/String;)I+2097
j  net.optifine.shaders.Shaders.setupProgram(Lnet/optifine/shaders/Program;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V+52
j  net.optifine.shaders.Shaders.init()V+707
J 21764 C1 net.optifine.shaders.Shaders.beginRender(Ldjw;Ldjh;FJ)V (939 bytes) @ 0x0000000004b1d7bc [0x0000000004b1d580+0x23c]
J 21763 C1 dzr.a(FJLdfj;)V (854 bytes) @ 0x000000000541a38c [0x000000000541a0a0+0x2ec]
J 9865 C1 dzr.a(FJZ)V (1147 bytes) @ 0x00000000040601ac [0x000000000405e9a0+0x180c]
J 9507 C1 djw.e(Z)V (946 bytes) @ 0x0000000003fa691c [0x0000000003fa19c0+0x4f5c]
j  djw.e()V+68
j  net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1366
v  ~StubRoutines::call_stub
j  sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0
j  sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100
j  sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+6
j  java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+56
j  net.minecraft.launchwrapper.Launch.launch([Ljava/lang/String;)V+661
j  net.minecraft.launchwrapper.Launch.main([Ljava/lang/String;)V+8
v  ~StubRoutines::call_stub```
jrbudda commented 4 years ago

I think I can provide some minor insight into what's going on here. This has been an issue since AMD driver 20.5.1 in June. The crash is caused by shader id re-use. Basically if you delete a shader in opengl, and then create a new one immediately after it gives you the id that was just deleted, which should be fine, but calling shaderSource on this ID crashes the driver, which is not fine.

It's technically a bug in the driver but given AMD's longstanding disinterest in opengl it might be worth applying a workaround of creating the new shader ids and then deleting the old ones, ensuring no immediate re-use.

Rolling back to AMD driver 20.4.2 should also stop the crashing.

bscout9956 commented 4 years ago

Same issue happens on NVIDIA. It's not a driver issue.

jrbudda commented 4 years ago

Same issue happens on NVIDIA. It's not a driver issue.

This issue, specifically the hardware-level crash in atio6axx.dll from a call to glShaderSource, most certainly does not occur on NVIDIA, given that, the last time I checked anyway, NVIDIA gpus do not use AMD gpu drivers.

chaosophy commented 4 years ago

I think I can provide some minor insight into what's going on here. This has been an issue since AMD driver 20.5.1 in June. The crash is caused by shader id re-use. Basically if you delete a shader in opengl, and then create a new one immediately after it gives you the id that was just deleted, which should be fine, but calling shaderSource on this ID crashes the driver, which is not fine.

It's technically a bug in the driver but given AMD's longstanding disinterest in opengl it might be worth applying a workaround of creating the new shader ids and then deleting the old ones, ensuring no immediate re-use.

Rolling back to AMD driver 20.4.2 should also stop the crashing.

Hi, thanks for the info, might try the suggested roll back and see if that works.

Other than AMD fixing their OGL drivers, which is pretty unlikely, do you think the work around you mentioned would be something on the Optifine side, or more likely something the shader devs need to be aware of?

I know you probably can't speak for the devs of either but I'm just wondering.

Thanks.

sp614x commented 4 years ago

AMD may be using multi-threading in the driver so deleting the shader doesn't really delete it, but puts it in the queue to be deleted by the resource thread, so recreating it immediately with the same ID could lead to a race condition.

chaosophy commented 4 years ago

AMD may be using multi-threading in the driver so deleting the shader doesn't really delete it, but puts it in the queue to be deleted by the resource thread, so recreating it immediately with the same ID could lead to a race condition.

Do you think this is something you'd add a work around for in Optifine? Or more of a shader side thing as it only seems to affect certain shaders more than others ?

thanks.

z0mbiesrock commented 4 years ago

@sp614x I do NOT have shaders enabled, and now I am getting the crashes constantly I also have a pathetically weak CPU, so I'm screwed.

z0mbiesrock commented 4 years ago

Confirmed issue is specific to which shaderpack is active. SEUS Renewed and Sildur's work fine, while BSL crashes going to the Overworld and projectLuma crashes going into the Nether.

I do NOT have shaders enabled, and am crashing constantly

AlphaQup99 commented 4 years ago

The same thing happens to me with Nvidia GTX 1050ti. With or without shaders, every time I try to portal into the nether it crashes my game. But sometimes I am able to portal into the nether but when I try to portal back to the Overworld it crashes. So every time I want to go into the nether and I'm using Optifine I have to save my game, quit the game and restart the game with Vanilla minecraft. Any idea why this could be happening? Any fix coming soon?

chaosophy commented 4 years ago

Rolling back to AMD 20.4.2 driver, as per jrbudda's suggestion, has fixed the issue for me. Which I'm glad works as at least I can play the game with shaders now but also a bit sad about as I feel getting AMD to fix it will be a pita.

For the nVidia users posting in this thread the issue here is specifically about a crash on AMD cards, not nVidia. As shown by 'atio6axx.dll' in the crash log.

If you are having a similar issue, then you probably need to open a separate thread and post your crash logs, spec, F3 screen etc so that can be looked at.

As per this post, the AMD issue here is fixed by rolling back to an earlier AMD driver, that is not going to work for you on nVidia.

If you feel it is the same issue, try rolling back your drivers to see if you can find one that works.

z0mbiesrock commented 4 years ago

So that means Optifine is no longer compatible with AMD-based drivers? Because it's painful for me to give my CPU a stroke just by starting up the game.

chaosophy commented 4 years ago

I have no idea tbh. The last recommended WHQL driver from AMD is 20.4.2 , every driver since has been 'optional'. So no idea where this stands with AMD, is it an intentional thing or a bug, will it be in the next WHQL release? Given AMD's seeming ambivalence to their OGL drivers, who knows.

I've also asked in this thread twice and once over on the shaderlabs discord if people think this could/would be fixed/worked around in either Optifine or the shaders but haven't had an answer.

When I can get to it i'll send a report thing to AMD and maybe post on their forums about it but tbh I've done similar before and never had a response from them.

jrbudda commented 4 years ago

Technically speaking this is an AMD/Minecraft bug. Vanilla minecraft uses shaders for a couple things (fabulous! mode and glowing entities, mainly), and uses the same creation pattern that can lead to this crash on resource reload. I'm surprised it's not a more widespread issue.

It could absolutely be worked around in Optifine, and even the vanilla shader issue could be corrected but only sp614x can tell you if that is going to happen.

chaosophy commented 4 years ago

Cheers jrbudda, thanks for the info.

z0mbiesrock commented 4 years ago

Technically speaking this is an AMD/Minecraft bug. Vanilla minecraft uses shaders for a couple things (fabulous! mode and glowing entities, mainly), and uses the same creation pattern that can lead to this crash on resource reload. I'm surprised it's not a more widespread issue.

It could absolutely be worked around in Optifine, and even the vanilla shader issue could be corrected but only sp614x can tell you if that is going to happen.

But the crash doesn't happen on vanilla Minecraft; only the Optifine builds are suffering from this.

chaosophy commented 4 years ago

Hi, an update on this.

Only done a quick test with one shader that I know had a problem before and it seems the the new AMD 20.9.2 drivers no longer have this issue.

Be interested to see if this is now works for anyone who still has the issue or is 'stuck' on 20.4.2 because it of.

Thanks.

Tasty213 commented 3 years ago

Hi, this is still an issue for me on the latest optifine version

Tasty213 commented 3 years ago

This is the error output as i go through the portal

[17:15:35] [main/ERROR]: OpenGL API ERROR: 2 (GL_INVALID_VALUE in glCopyBufferSubData(readOffset 15825152 + size 26624 > src_buffer_size 0))
java.lang.Exception: Stack trace
    at org.lwjgl.opengl.GL31C.glCopyBufferSubData(Native Method) ~[lwjgl-opengl-3.2.2.jar:build 10]
    at org.lwjgl.opengl.GL31.glCopyBufferSubData(GL31.java:298) [lwjgl-opengl-3.2.2.jar:build 10]
    at net.minecraft.class_4493.copyBufferSubData(class_4493.java:2104) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.optifine.render.VboRegion.copyVboData(VboRegion.java:243) [Optifine-mapped.jar:?]
    at net.optifine.render.VboRegion.compactRanges(VboRegion.java:157) [Optifine-mapped.jar:?]
    at net.optifine.render.VboRegion.finishDraw(VboRegion.java:338) [Optifine-mapped.jar:?]
    at net.minecraft.class_761.drawRegion(class_761.java:2309) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_761.method_3251(class_761.java:2230) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_761.method_22710(class_761.java:1594) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_757.method_3188(class_757.java:1022) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_757.method_3192(class_757.java:693) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_310.method_1523(class_310.java:1048) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.class_310.method_1514(class_310.java:681) [intermediary-minecraft-1.16.4-client.jar:?]
    at net.minecraft.client.main.Main.main(Main.java:215) [intermediary-minecraft-1.16.4-client.jar:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:224) [fabric-loader-0.10.8.jar:?]
    at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:141) [fabric-loader-0.10.8.jar:?]
    at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:27) [fabric-loader-0.10.8.jar:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
    at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
    at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
    at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
[17:15:35] [main/ERROR]: [OptiFine] OpenGL error: 1281 (Invalid value), at: Copy VBO range
Julesssss commented 3 years ago

Still having this problem with AMD version 20.12.1