libretro / flycast

Flycast is a multiplatform Sega Dreamcast emulator. NOTE: No longer actively developed, use upstream repo for libretro from now on - https://github.com/flyinghead/flycast
http://reicast.com
GNU General Public License v2.0
155 stars 77 forks source link

Savestates support #204

Closed inactive123 closed 5 years ago

inactive123 commented 6 years ago

Hey @RetroSven, going by the awesome job you have managed to do so far when it comes to serialization support for cores like MAME and rumble support, I'm not sure if this task would be daunting for you but I'd like to propose it anyways -

Reicast completely lacks any kind of serialization support right now, meaning it isn't possible to do savestates at all. It is not even possible on standalone, and the author feels no incentive to add it.

Is this something you would be interested in looking into? You don't have to promise anything of course.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/62027304-savestates-support?utm_campaign=plugin&utm_content=tracker%2F49543223&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F49543223&utm_medium=issues&utm_source=github).
RetroSven commented 6 years ago

yes you might need to redirect the output of retroarch to a log file when you start it - not sure how you start RA, but you can do so from the command line:

./retroarch -v >ra.log 2>&1

then upload ra.log to pastebin

blisstik commented 6 years ago

In the pastebin - I noticed bm_Reset() ; was inserted back above #if !defined(TARGET_NO_THREADS)

RetroSven commented 6 years ago

oops yeah - that won't affect your test though since you can't even get something to save, let alone load, but here's an updated one:

https://pastebin.com/4xKHzi9k

blisstik commented 6 years ago

Here's a log of the FIRST pastebin link you sent, captured on character selection screen of CvS2 after freezing of course.

https://pastebin.com/GdTRTdrM

RetroSven commented 6 years ago

and it just freezes at that point?

will you please convert that to a pastebin and delete the post? It will make this issue easier to navigate

blisstik commented 6 years ago

Done and yes, it freezes up to that point then I capture the log.

blisstik commented 6 years ago

@RetroSven - does retroarch need to be updated to the latest as well? I'm on 1.7.3

RetroSven commented 6 years ago

@6alileo probably worth trying - also have you tried saving from inside the emu (i.e. don't bring up the GUI menu and select save state - instead use F2/F4 or bind it to a joypad mapping)

RetroSven commented 6 years ago

please also run this from your build directory and post the results:

grep -r ngen_mainloop *

blisstik commented 6 years ago

@RetroSven - it's working now by using hotkey+button for save/load! So the freezing issue is on the RetroArch old-green GUI on RA 1.7.3 and 1.7.4

blackman91 commented 6 years ago

The freezing also happens using the xmb ui, so maybe doing the save or load state via the quickmenu is the problem.

blisstik commented 6 years ago

Is this an issue with RetroArch and be reported there or is it related to this core only?

blackman91 commented 6 years ago

On Android with the reicast option threaded rendering enabled the save and load states work if you use shortcuts or the onscreen overlay: screenshot_20180829-172833

RetroArch freezes if you use save or load via the quickmenu with threaded rendering on, but it doesn't happen with threaded rendering off.

On Windows loading a state via the quickmenu sometimes freezes RetroArch but using shortcuts works fine.

blackman91 commented 6 years ago

Also RetroArch crashes if you press the home button or recent apps Android button and go back to the reicast core or if you get a phone call and go back, could this be solved with the new save states?

RetroSven commented 6 years ago

please retest with https://github.com/libretro/reicast-emulator/pull/233

blisstik commented 6 years ago

@RetroSven - with threaded rendering enabled, I was not able to save state using the quick menu but I was able to via hotkey+button. Then restarted and I was able to load state using the quick menu.

blackman91 commented 6 years ago

Still freezing mostly but now the saving and loading work via the quickmenu sometimes on Android with threaded rendering option enabled.

RetroSven commented 6 years ago

it should at least not freeze indefinitely - if it fails to load/save control should resume in 5 seconds

inactive123 commented 6 years ago

When it rains it pours, heh -

I know you are already busy @RetroSven but wanted you to know that the Android JNI solution is failing right now -

http://p.0bl.net/35985

I think the issue is probably easy to fix though.

RetroSven commented 6 years ago

fix for compile issue which may also fix the freezing https://github.com/libretro/reicast-emulator/pull/235

Deivmsr commented 6 years ago

I tested the 6d20ee5 build on my Note 8 / Exynos and used the 30-08-2018 version of Retroarch. The load / save state of the quick menu only really works if I disable the "Pause when menu activated" option in Settings / User Interface. If "Pause when menu activated" is enabled the emulator freezes when saving state by the quick menu, the emulator stops working and after returning to the emulator, load the game and pass the DC and Sega Enterprises Screen screens when trying to load the save the emulator freezes again in 96%.

blisstik commented 6 years ago

Good find @Deivmsr - I also can confirm that on ARM, it works when disabling "Pause when menu activated" in Settings -> User Interface.

Paging @flyinghead - is this on the RA side?

RetroSven commented 6 years ago

can you all please confirm that loading (not saving) states from the menus works 100%?

blisstik commented 6 years ago

@RetroSven - yes loading works via Quick Menu after saving state using hotkey+button (R1)

blisstik commented 6 years ago

RetroArch #7156 fixed the issue. Thank you @RetroSven for your determination in getting this fixed. And all the testers, please verify.

inactive123 commented 6 years ago

BTW, if you're on Windows, it is now easier than ever to update to the latest nightlies.

https://www.youtube.com/watch?v=l_n9pU-bfFs

You might have to wait sometime for the latest update to become available from within the app, though, so sometimes when you absolutely need the latest version right at this point in time, buildbot.libretro.com/nightly might still be a better option.

blackman91 commented 6 years ago

Using RetroArch latest nightly 02e23be the reicast save states now work perfectly on Android with threaded rendering enabled via the quickmenu, awesome job RetroSven. RetroArch crashing if you press the home button or recent apps Android button and go back to the reicast core is still present but with the working save states is not a big issue anymore.

RetroSven commented 6 years ago

@twinaphex has that issue with the power stone background gone away for you?

inactive123 commented 6 years ago

@bparker06 Maybe you could help as well? @RetroSven and others are trying to get rid of savestate crashes/freezes that happen with threaded rendering in Reicast. A PR was sent to RetroArch which apparently was needed in order to solve some of these issues, however, it led to savestate corruption in many cores like Snes9x and Fceumm for @Tatsuya79, so I had to revert it.

So hopefully some experienced people that know how to deal with memory corruption issues could be of help to @RetroSven so that we can nail this part.

inactive123 commented 6 years ago

@RetroSven - I'll be sure to test, thanks.

flyinghead commented 5 years ago

Savestates are now supported