mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.64k stars 772 forks source link

Games freezing upon saving #2857

Open Kiyuja opened 1 year ago

Kiyuja commented 1 year ago

Since the last two builds there seems to be a bug. Every 2nd or 3rd attempt of writing to a save file causes the game to freeze. Good news are only the game is affected as the menus still work properly and the freezing only occurs after the saving process is completed, meaning no actual progress is lost you just have to restart with ctrl+0 and you can resume the game. Additional info could be that the ROM and its save file are stored on an HDD meanwhile mGBA is stored on an SSD. Maybe mBGA doesnt know what to do if an older HDD doesnt respond in a timely manner but I dont think thats the issue as three builds ago this didnt occur... While we're at it can we have an option to disable analog trigger input? I love to use the right trigger as a temporal speed up but the current implementation of mGBA makes it weird to use it as a toggle/ held down option as it reads the accurate +/- values of the controller. This however is kinda useless on a GBA and makes mapping something to the triggers really awkward.

Kiyuja commented 1 year ago

This was tested on multiple games (Golden Sun, Sonic Advance 3, Castlevania Aria of Sorrow, Metroid Zero Mission) to make sure its not a corrupt ROM or something.

endrift commented 1 year ago

Please upload a bug report zip generated while a game is loaded.

endrift commented 1 year ago

It's worth noting that I can't reproduce this locally, and there haven't been any changes to saving in the last 3 builds (except for how the paths themselves are handled, but that's only done when the game is loaded initially).

Kiyuja commented 1 year ago

On rare occasions the game had minor issues when booted into mGBA. But again the ROMs and their respective save files (I'm talking about the actual game saves, no save states etc.) are stored on an older HDD. I de-dusted VisualBA to test by saving over and over again but it didnt occur there. After creating the first bug .zip I updated mGBA and it wasnt as easy to trigger anymore, "problem solved" I thought, But I got it to trigger again. I created a second .zip (dunno if that helps) and in the crashed state I grabbed mGBAs logs. This may actually be the culprit as there are many bad memory errors. I will attach the logs as a .txt file. I'm starting to believe its just the HDD being on its death bed idk. In any case thank you for the quick response!

report file.zip report file during crash.zip crash log.txt

Kiyuja commented 1 year ago

I had some time to spend on this again. When I wrote my last comment I started Windows defrag on the HDD and sure enough it took over 7 hours to completely defrag (dont you love HDD technology). This however did not fix the issue (even tho it coul've been contributing to this). I used other software like CEMU(WiiU), Dolphin(Wii/GC) and Yuzu(Switch, still under heavy developement). None of these emulators crashed/froze upon saving or in general, no matter if manual or auto saving was in use. The storage situation is the same for all: emulator stored on an SSD while saves and roms are stored on the aformentioned HDD. I updated mGBA today to the latest dev build and it does still occur. The logs say bad access and store to basically anything. Bad BIOS load, Bad Memory store 32, Bad Memory load 32 for example when leaving and entering towns in Golden Sun(game is still playing normally tho). I noticed in the logs that the erasing of flash still worked normally but then it just hangs the game(again its just the gameplay being frozen, menus are still accessible and the actual progress of the game is saved, meaning ctrl+0 and resuming the game works, its just anoying having this every 2nd or 3rd saving attempt).

Is there any hint at what could cause this permanent Bad Memory behavior? Like an Exception being thrown that isnt handled or something? Is there a piece of source that we can look at that would usually handle this? Is there any additional information I can provide except the log and bug file?