Ryujinx / Ryujinx

Experimental Nintendo Switch Emulator written in C#
https://www.ryujinx.org
MIT License
34.61k stars 3.95k forks source link

[Bug] Replacement of images in CrossCode triggers crash -- looks to be graphics engine related #4485

Open Nazosan opened 1 year ago

Nazosan commented 1 year ago

Description of the issue

The game CrossCode uses some sort of HTML5 interpreter engine. Graphics for it are provided as plain .png files (ordinary 32-bit RGBA.) I thought I might try modifying a few (vibrancy, etc and maybe a UI thing or two) but on my initial test (just to see if it works the first thing I did was modify a single image on the title screen just so I could tell) I found that even just replacing one file caused Ryujinx and Yuzu to crash (well, Yuzu crashes if I accidentally breath too hard, so I take that with a grain of salt, but it is interesting that both dislike this game.) Interestingly the same image does not cause a crash on my real Switch. Placing the original png in that location was alright. I think this may be more important than just a single game not liking mods though because it seems to be triggering a graphics engine crash rather than just simply something going wrong. Which might point to possible issues with other games (especially if any ever use the same basic engine.) Of note here too, it didn't seem to want to start with Vulkan even without any mod files present which further points to something it does causing graphics engine issues I think. (Perhaps in classic game fashion it uses some sort of hardware hacks to try to get better performance -- hacks that emulators don't like.)

Reproduction steps

  1. Place a modified PNG for an image in an appropriate directory. For example, I modified romfs\media\parallax\title\lea.png to put the word "test" on the character so I would see on the title screen if it worked.
  2. Run the game. It crashes during early startup phases.

Log file

Ryujinx_1.1.595_2023-02-26_01-11-57.log

OS

Windows 10 22H2 x64

Ryujinx version

1.1.595

Game version

Base (1.0.2) or update (1.0.15)

CPU

Ryzen 5 5600x

GPU

nVidia RTX 3060 TI

RAM

32GB

List of applied mods

One modified PNG

Additional context?

I only intended to use Ryujinx for testing the modifications to make sure the Switch would be fine with them (I also own the PC version of the game, so it would be better for actually playing on PC, however I wanted to mod the Switch version) and consider the game specific issues unimportant, but I do wonder if the specific problem could point to potential trouble with other things down the road besides this one game, so I wanted to share in case it might be helpful.

I have attempted saving the file in a number of different ways, trying to match the properties of the original as well as I could, but so far haven't found anything that did work. The issue may be at least somewhat game-specific given that I can put the original PNG in the mod directory and it won't crash but any changes cause a crash, however, since the crash is only in emulators and not on the real Switch it's hard to really be sure if that really is the case.

The key detail seems to be this line in the log:
00:00:03.327 |E| GPU.MainThread Application : Unhandled exception caught: Ryujinx.Memory.InvalidMemoryRegionException: va=0xFFFFFFFFFFFFFFFF, size=0x0000000000001000

Unfortunately I don't really know what that means or what would cause it in this very specific case.

I should probably add that I have used mods (graphics, sound, etc) with other games with no problems, so it's not something specific in my setup in that regard causing issues. It is only this one game that crashes in this specific manner.

gdkchan commented 1 year ago

The log file is empty, also the emulator version is outdated.

Nazosan commented 1 year ago

Alright. I didn't think the version number was a big deal since it was unlikely anything major changed in the graphics engine since I updated last only a few days ago, but I grabbed the latest as of right now (1.1.643) and ran it again with the same result. I have no idea how the log file failed to upload correctly though. Sorry about that. I'll try again. Ryujinx_1.1.643_2023-02-26_15-47-16.log

Squall-Leonhart commented 1 year ago

You need to be real sure your png replacement is in the right export format, recently a number of applications began exporting png files with pre-multiplied alpha by default, which is not officially png spec.

The traditional gif export is now available via such apps "Export To web" tool

Nazosan commented 1 year ago

Well, I'll admit to being vaguely curious as to how to get it to not crash, but I only really use the emulators for testing stuff and my real Switch for actual gaming, so that's a fairly low priority to me really. Mostly I just wanted to pass along that it's creating a situation where Ryujinx and Yuzu both completely crash outright but the real Switch does not. It's probably unlikely, but it can't be 100% ruled out that an actual game (not just a mod) could someday trigger the same issue and the devs just get lazy and not fix it because it works on the real thing anyway.