vram-guild / canvas

Shader-Based Minecraft Renderer for Fabric
GNU Lesser General Public License v3.0
418 stars 40 forks source link

Certain Resourcepacks Cause Hard Crash on Load [Group Animated Sprites] #353

Open heymanMC opened 2 years ago

heymanMC commented 2 years ago

System Information

Other mods and versions installed

or

    • Start MC with no resourcepacks enabled
    • Log onto a singleplayer world
    • Enable the resourcepack from the menu
    • Game will crash

Logs and screenshots

Crash while enabling the resourcepack in game: https://paste.ee/p/VgV7p Crash while starting the game with the resourcepack: https://paste.ee/p/QPtRr

Resourcepacks

https://www.curseforge.com/minecraft/texture-packs/default-improved-plus

FwuffyPe†sOwO~#7236 also said they experience this with this pack: https://www.curseforge.com/minecraft/texture-packs/dragon-dance-renaissance

I am going to try disabling parts of the pack (Default Improved) to try to get the game to load. Anything found will be commented here.

heymanMC commented 2 years ago

I get this error from time to time after enabling the resourcepack in game if it helps.

[11:57:06] [Render thread/INFO]: Reloading ResourceManager: Default, Fabric Mods (Canvas Renderer, Cloth Config v6, Fabric API Base, Fabric Key Binding API (v1), Fabric Lifecycle Events (v1), Fabric Resource Loader (v0), Fabric Loader, FREX, JSON Model Extensions), LumiPBRExt-v0.22.zip, emissive-ores.zip, LumiLights-wip-12-15-21, canvas/canvas_default, DefaultImprovedPlus-TestCanvas
[11:57:07] [Worker-Main-35/WARN]: Unused frames in sprite minecraft:entity/conduit/wind: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
[11:57:07] [Worker-Main-38/WARN]: Unused frames in sprite minecraft:entity/conduit/wind_vertical: [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
[11:57:07] [Render thread/INFO]: OpenAL initialized on device OpenAL Soft on Headphones (Jabra Elite 85h Stereo)
[11:57:07] [Render thread/INFO]: Sound engine started
[11:57:07] [Render thread/INFO]: Created: 4096x2048x4 minecraft:textures/atlas/blocks.png-atlas
[11:57:07] [Render thread/INFO]: Created: 1024x512x4 minecraft:textures/atlas/signs.png-atlas
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000027d36894176, pid=39752, tid=42492
#
# JRE version: OpenJDK Runtime Environment Temurin-17.0.1+12 (17.0.1+12) (build 17.0.1+12)
# Java VM: OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (17.0.1+12, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, windows-amd64)
# Problematic frame:
# v  ~StubRoutines::jlong_disjoint_arraycopy
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
[thread 7332 also had an error]
# An error report file with more information is saved as:
# C:\MultiMC\instances\1.18\.minecraft\hs_err_pid39752.log
Compiled method (c2)  226230 13346       4       org.lwjgl.system.MemoryUtil::memCopy (41 bytes)
 total in heap  [0x0000027d3e759910,0x0000027d3e759de0] = 1232
 relocation     [0x0000027d3e759a68,0x0000027d3e759a80] = 24
 main code      [0x0000027d3e759a80,0x0000027d3e759c60] = 480
 stub code      [0x0000027d3e759c60,0x0000027d3e759c78] = 24
 oops           [0x0000027d3e759c78,0x0000027d3e759c88] = 16
 metadata       [0x0000027d3e759c88,0x0000027d3e759cd8] = 80
 scopes data    [0x0000027d3e759cd8,0x0000027d3e759d88] = 176
 scopes pcs     [0x0000027d3e759d88,0x0000027d3e759dd8] = 80
 dependencies   [0x0000027d3e759dd8,0x0000027d3e759de0] = 8
Compiled method (c2)  226233 11230       4       grondag.canvas.varia.GFX::texParameter (58 bytes)
 total in heap  [0x0000027d3e533010,0x0000027d3e533298] = 648
 relocation     [0x0000027d3e533168,0x0000027d3e533188] = 32
 main code      [0x0000027d3e5331a0,0x0000027d3e533200] = 96
 stub code      [0x0000027d3e533200,0x0000027d3e533228] = 40
 oops           [0x0000027d3e533228,0x0000027d3e533230] = 8
 metadata       [0x0000027d3e533230,0x0000027d3e533238] = 8
 scopes data    [0x0000027d3e533238,0x0000027d3e533248] = 16
 scopes pcs     [0x0000027d3e533248,0x0000027d3e533278] = 48
 dependencies   [0x0000027d3e533278,0x0000027d3e533280] = 8
 handler table  [0x0000027d3e533280,0x0000027d3e533298] = 24
Compiled method (c1)  226240 22812   !   3       org.lwjgl.opengl.GL11C::glGenTextures (46 bytes)
 total in heap  [0x0000027d37855c90,0x0000027d37856fb8] = 4904
 relocation     [0x0000027d37855de8,0x0000027d37855ef0] = 264
 main code      [0x0000027d37855f00,0x0000027d37856b00] = 3072
 stub code      [0x0000027d37856b00,0x0000027d37856ba8] = 168
 oops           [0x0000027d37856ba8,0x0000027d37856bb0] = 8
 metadata       [0x0000027d37856bb0,0x0000027d37856c00] = 80
 scopes data    [0x0000027d37856c00,0x0000027d37856d80] = 384
 scopes pcs     [0x0000027d37856d80,0x0000027d37856f10] = 400
 dependencies   [0x0000027d37856f10,0x0000027d37856f28] = 24
 handler table  [0x0000027d37856f28,0x0000027d37856fa0] = 120
 nul chk table  [0x0000027d37856fa0,0x0000027d37856fb8] = 24
#
# If you would like to submit a bug report, please visit:
#   https://github.com/adoptium/adoptium-support/issues
#
AL lib: (EE) alc_cleanup: 1 device not closed
Process exited with code 1.
wouu commented 2 years ago

i've suffered a similar fatal jvm crash with the drink beer mod, only relevant info i'm getting in the log is this:

Process crashed with exitcode -1073740940.

since the errorcodes are different, they could be for different reasons, but since this is the only reason i can think of for why the crash happens between these two mods, i'll post it as a comment under this issue, because i didn't want to make a dupe issue if they are for the same reason.

it did also give the same jvm fatal error message shown here at times, but it didn't happen all of the time.

heymanMC commented 2 years ago

More insight: If I remove just the entity folder from Default Improved, the game is able to load just fine and works.

Pikalyx commented 2 years ago

I get the same issue myself with the texture pack https://www.curseforge.com/minecraft/texture-packs/jicklus

Log: https://paste.ee/p/Ac9YY

had the same exit code of -1073740940 as well if it helps.

Pikalyx commented 2 years ago

Removing the entity folder also works for my machine.

heymanMC commented 2 years ago

Figured out the specific textures causing the issue:

assets/minecraft/textures/entity/shield_base.png
assets/minecraft/textures/entity/shield_base_nopattern.png

Removing these textures from the pack fixes the crashing. So, it looks like something is wrong when stitching the atlas for the base of a shield for some reason.

These textures may be redundant in the latest 1.18 resource pack version since there is a entity/shield/base.png texture however, the game should not crash for redundant textures.

jardhu commented 2 years ago

@heymanMC, can you try setting "groupAnimatedSprites": false in the Canvas config and reloading the resource pack(s) in question?

spiralhalo commented 2 years ago

As jardhu said, this seem to be caused by Group Animated Sprites. Interesting that certain sprites are causing it though, certainly will be helpful in fixing this issue.

jardhu commented 2 years ago

I suspect it's something to do with texture size. Any texture in this directory that is larger than 32x32 causes crashes upon the game loading, reloading resource packs, entering a world, generating chunks, etc.

The errors are almost always heap corruptions and access violations deep inside C libraries, which hinted to me that there's some kind of upper-level memory corruption going on.

getchoo commented 2 years ago

i've been able to recreate this with faithful 32x as well as bare bones; disabling group animated sprites fixed it. i got a pretty detailed crash log from the jre here with a similar access violation from other reports. i like this project a lot but this has honestly been a bit frustrating until i found a fix here. i hope maybe the log can help a bit :)

jardhu commented 2 years ago

According to @getchoo's log this crash is occurring at the MemoryUtil.memCopy call here.

Definitely some kind of memory corruption, but I don't know how neither Minecraft's texture memory nor the combined sprite algorithm work so I can't reasonably debug this any further.

getchoo commented 2 years ago

taking a wild guess here, but it seems like the pointers are just being miscalculated with specific sprites - thus the access violation. to be more specific, i think the culprit could be a precision error from converting the ints srcY and destY to longs (seen here and here). maybe with larger sprites the precision isn't enough or something?

edit: wasn't thinking, it would be the destination parameter of memcopy; so the issue causing the crash would most likely be in the conversion of destY, but a similar error could be happening with srcY if that's the case - which would also copy the wrong area of memory