txnimc / MagnesiumExtras

10 stars 18 forks source link

VRAM leak and JVM crash #52

Open tom5454 opened 1 year ago

tom5454 commented 1 year ago

Minecraft version: 1.19.2 Forge version: tested with both 43.2.19 and 43.2.17 Modlist: rubidium_extras-1.19.2_v1.4.3.jar rubidium-0.6.2b.jar

Using ComplementaryReimagined_r2.2.1 shader with Oculus Happens without Oculus installed with a lesser effect (the object count still grows at the same rate, but uses less VRAM?) Oculus version: oculus-mc1.19.2-1.6.4.jar

The worst case scenario in my testing is flying in the Twilight Forest with shaders on, leaks 6 GB of VRAM every 1000ish blocks. Crashes around 1500-2000 blocks (tested multiple times with NVIDIA RTX 3060). Running the same test wthout rubidium extras only uses a maximum of 2GB of VRAM, and goes up and down as needed. Flew 4000 blocks in the same chunks, between two waypoints.

Reproduction: Create a new world and start flying in one direction See your Device memory and objects increase. If you reach your GPU's max VRAM amount, the minecraft log has this message spammed

[15júl.2023 02:34:11.557] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=0, source=API, type=ERROR, severity=HIGH, message='Unknown internal debug message. The NVIDIA OpenGL driver has encountered
an out of memory error. This application might
behave inconsistently and fail.
(pid=34720 javaw.exe 64bit)'
[15júl.2023 02:34:11.557] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1285, source=API, type=ERROR, severity=HIGH, message='GL_OUT_OF_MEMORY error generated. Failed to allocate memory for buffer data.'
[15júl.2023 02:34:11.557] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1281, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_VALUE error generated. Invalid size and/or offsets.'
[15júl.2023 02:34:11.558] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1281, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_VALUE error generated. Invalid size and/or offsets.'
[15júl.2023 02:34:11.558] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1281, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_VALUE error generated. Invalid size and/or offsets.'
[15júl.2023 02:34:11.558] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1281, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_VALUE error generated. Invalid size and/or offsets.'
[15júl.2023 02:34:11.564] [Render thread/INFO] [com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1281, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_VALUE error generated. Invalid size and/or offsets.'

Then the jvm crashes with EXCEPTION_ACCESS_VIOLATION if you keep loading new chunks. Relevant stacktrace from the hs_err file:

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J 47233  org.lwjgl.opengl.GL32C.nglMultiDrawElementsBaseVertex(IJIJIJ)V org.lwjgl.opengl@3.3.1+7 (0 bytes) @ 0x00000207d0860083 [0x00000207d0860020+0x0000000000000063]
J 49792 c2 me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer.executeDrawBatches(Lme/jellysquid/mods/sodium/client/gl/device/CommandList;Lme/jellysquid/mods/sodium/client/gl/tessellation/GlTessellation;)V rubidium@0.6.2b (122 bytes) @ 0x00000207d0cbe3b0 [0x00000207d0cbdc80+0x0000000000000730]
J 65320 c2 me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer.render(Lme/jellysquid/mods/sodium/client/render/chunk/ChunkRenderMatrices;Lme/jellysquid/mods/sodium/client/gl/device/CommandList;Lme/jellysquid/mods/sodium/client/render/chunk/ChunkRenderList;Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass;Lme/jellysquid/mods/sodium/client/render/chunk/ChunkCameraContext;)V rubidium@0.6.2b (190 bytes) @ 0x00000207d10939bc [0x00000207d1092e80+0x0000000000000b3c]
...
tom5454 commented 1 year ago

Update: Manually removing the ExtendedServerViewDistanceMixin from the mixins json seems to fix the issue.

collective169 commented 1 year ago

Update: Manually removing the ExtendedServerViewDistanceMixin from the mixins json seems to fix the issue.

Can you please tell more on how to implement it? I dont really understand what does that mean but it seems like i am getting the same issue, same crash, same reproduction but i can't get rid of it

tom5454 commented 1 year ago

Remove the mod until it's fixed by the developer.

Or clone the repo and build a modified version of the mod yourself, and remove this line: https://github.com/anthxnymc/MagnesiumExtras/blob/1.20/src/main/resources/rubidium_extras.mixins.json#L18 This will disable the extended view distance feature, which causes the issue.

SrRapero720 commented 10 months ago

@tom5454 can you test if this issue happens without removing that mixin and also using this mod? https://www.curseforge.com/minecraft/mc-mods/fix-gpu-memory-leak

i was trying to figure out why leak is caused by that mixin but i didn't found anything, and i can't replicate that issue