Skip to content

Savedata dialog: serialize ioThreadStatus (bump section to v3) - #21987

Open
Arkadyzja wants to merge 1 commit into
hrydgard:masterfrom
Arkadyzja:savedialog-serialize-iothreadstatus
Open

Savedata dialog: serialize ioThreadStatus (bump section to v3)#21987
Arkadyzja wants to merge 1 commit into
hrydgard:masterfrom
Arkadyzja:savedialog-serialize-iothreadstatus

Conversation

@Arkadyzja

Copy link
Copy Markdown

What

One-line fix (plus a comment): bump the PSPSaveDialog savestate section from max version 2 to 3, which activates the existing-but-dead s > 2 branch that serializes ioThreadStatus.

The bug

The if (s > 2) { Do(p, ioThreadStatus); } branch in PSPSaveDialog::DoState appears to have been dead code since it was written — the section declaration stayed at p.Section("PSPSaveDialog", 1, 2), so the version can never exceed 2 and every load takes the else path, resetting ioThreadStatus to SAVEIO_NONE.

Consequence: loading a state that was taken while a savedata operation was in flight loses the operation's completion status. Depending on where the dialog's state machine was, it either repeats the IO or waits on a completion that has already happened, instead of resuming from the recorded status.

Why restoring the value is safe

  • DoState joins the IO thread (ioThread.join()) before serializing anything, so the value that ends up in the state is only ever SAVEIO_NONE or SAVEIO_DONE — never a mid-operation status.
  • The effects of a completed operation are already part of the serialized state (emulated RAM / savedata results), so restoring SAVEIO_DONE is consistent with the rest of the loaded state.

Compatibility

  • Old (v2 and v1) states load exactly as before, through the reset path.
  • States written by this build won't load on older builds — the usual consequence of a section version bump.

The s > 2 branch in PSPSaveDialog::DoState has been dead code since it
was written - the section version was never raised past 2, so
ioThreadStatus was reset to SAVEIO_NONE on every savestate load.
Loading a state that was saved while a savedata operation was in
flight then repeated the operation (or left the dialog waiting on a
completion that had already happened), instead of resuming from the
recorded status.

Restoring the value is safe: DoState joins the IO thread before
serializing, so the stored status is only ever SAVEIO_NONE or
SAVEIO_DONE, and the operation's effects are already part of the
serialized emulated RAM. Old (v2) states still load through the reset
path.
@hrydgard hrydgard added this to the v1.21 milestone Jul 27, 2026
@hrydgard hrydgard added Saving issue Prevents or obstructs saving game (not save states.) I/O Affected by I/O timing settings, or other kind of I/O issue. labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I/O Affected by I/O timing settings, or other kind of I/O issue. Saving issue Prevents or obstructs saving game (not save states.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants