Skip to content

Save state fixes

Libretro-Admin requested to merge github/fork/jdgleaver/save-state-fix into master

Created by: jdgleaver

This is a follow up to PR #249. It includes the following fixes:

  • At present, any call to retro_update_av_info() that occurs outside of retro_run() is ignored (since it is unsafe to invoke this anywhere else). Such calls may happen on the first frame, and when loading a save state - and it turns out that this can cause problems in certain edge cases. For example, when running some NTSC content, we end up with the wrong video dimensions (until the next resolution change). This sort of error was hard to detect! Many apologies for missing it. This PR fixes the issue by deferring any av info updates that occur outside the main runloop to the next call of retro_run().

  • It turns out that rewind functionality can break in certain games due to an increase in save state size during runtime. This PR now sets a fixed save state size (determined at load content), so the frontend no longer has to deal with changing buffer sizes. Rewind should now always work in all cases.

NOTE: With the fixed size save states, and after some further investigation, I can confirm that runahead now works in most cases - but only if it is enabled after content is fully loaded.

Basically, there is window of ~300 frames at the start of the emulation runloop where we cannot save/load states on adjacent frames. This seems fundamental to the underlying puae code, and I have no idea how to fix it (or even if it can be fixed). But if runahead is enabled after this, it is actually quite useable - although it requires a beefy CPU.

Merge request reports