fix(libSceSaveData.native): back up and deliver event in sceSaveDataUmount2 #23789
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23789"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-19T16:54:17Z.
What
sceSaveDataUmount2ignored itsmode. A title that unmounts with0x10000(back up on unmount) receives aSAVE_DATA_EVENT_TYPE_UMOUNT_BACKUPevent once the backup is written, and may wait for it throughsceSaveDataGetEventResult. AnyPS5 unmounted without a backup and without the event, so such a title waited forever.Lies of P (PPSA10621 01.012) does this on a cold first run:
TaskGraphThreadHPcreatesAccount1andOptionSlot.sceSaveDataUmount2(0x10000, ...)while holding the game's save mutex.GameThreadwaits for that mutex.The game stalls on the loading screen before the main menu, and again when New Game creates its slots. A run that finds both slots on disk mounts them read-only and unmounts with mode 0, so it reaches the menu; that is why only runs that had to create the slots stalled.
#5983 is the same stall on another release of the game, PPSA10261 01.005.001, which freezes on "Now Lying...". With this change a cold PPSA10261 run with no save data reached the menu and played a New Game. The
WAIT_REG_MEMtimeouts discussed there are not the cause: that run still logged nine of them and carried on.sceSaveDataUmount2now handles each mode as follows:0: unmounts without a backup or an event, as before.0x10000(SAVE_DATA_UMOUNT_MODE_BACKUP) and0x10001(withSAVE_DATA_UMOUNT_MODE_BACKUP_FORCE): unmounts and copies the backup. It queuesSAVE_DATA_EVENT_TYPE_UMOUNT_BACKUP, withSAVE_DATA_ERROR_INTERNALif the copy fails, and delivers it to a registered callback. This is whatsceSaveDataUmountWithBackupalready does; both now share one function.What stays the same:
sceSaveDataUmount), unmounts exactly as before.sceSaveDataUmountWithBackupruns the same steps in the same order, now through the shared function.0x10001was already used by an upstream test (CheckPreparedCreate2inGuestSaveDataIcon.cpp), where it only unmounted. It now backs up, and the backup event carries the title ID, so that test now provides aparam.json, assceSaveDataUmountWithBackupalready requires.Changes
libSceSaveData.native/SaveData.hpp:SAVE_DATA_UMOUNT_MODE_BACKUP(0x10000) andSAVE_DATA_UMOUNT_MODE_BACKUP_FORCE(0x1).libSceSaveData.native/Export.cpp:unmountMountPoint, shared bysceSaveDataUmount2andsceSaveDataUmountWithBackup, and the mode handling above.GuestSaveDataMountStatus.cpp:0x10000,0x10001and0; a failing backup copy, which still unmounts and returns 0 but reportsINTERNALin the event; an unknown mode throws.GuestSaveDataEventCallback.cpp: the0x10000event reaches the callback once.GuestSaveDataIcon.cpp:param.jsonfor the existing0x10001case.docs/dev/debt/changes/fix-savedata-umount2-backup.md: forced and ordinary backups are not told apart, and an unchanged save is still copied. Not measured on a console.Tested
Windows 11 Pro (build 26300), MinGW-w64 GCC 15.3.0, Release build with tests.
The 22 SaveData test programs, on
maind7be67833eand on this change, same machine:main: 38 tests, all passed. This change: the same 38, all passed. The new cases are insideguest_savedata_mount_status,guest_savedata_event_callbackandguest_savedata_icon.main'sExport.cppunder these tests,guest_savedata_mount_statusfails (umount2(65536) posts an event) andguest_savedata_event_callbackfails (umount2(0x10000)'s completion reaches the callback within 5 s).public_headers: 65/65 passed.tools/check_conventions.py --base origin/mainandtools/debt_fold.py --check: passed.tools/pr_overlap.py: no open pull request implementssceSaveDataUmount2orsceSaveDataUmountWithBackup, or changes the same lines. #15650 and #18674 conflict withmainand share files; neither touches the unmount code.Lies of P (PPSA10621 01.012), #22009, on an earlier
main(d31916ed37) with #16053 reverted so the picture is upright (#20827 does this onmainnow):APS5_PLAYGO_UNLISTED_CHUNKS=installedandAPS5_GPU_WAIT_TIMEOUT_MS=60000: seven runs in all. With both slots already on disk the menu came up, and New Game then stalled.sceSaveDataUmount2(0x10000)forAccount1andOptionSlotbacked both up and delivered the event.Lies of P (PPSA10261 01.005.001), #5983, same machine and base, with #23790 as well (neither touches SaveData):
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T17:17:06Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
290d2f46b1:tools/check_conventions.pypassed.guest_savedata_event_callback_tests,guest_savedata_icon_tests,guest_savedata_mount_status_testsbuilt cleanly.guest_savedata_mount_status,guest_savedata_event_callback,guest_savedata_icon_roundtrip,guest_savedata_icon_bounds,guest_savedata_icon_readonly,guest_savedata_icon_prepared_create2,guest_savedata_icon_arguments,guest_savedata_icon_io):core/libs/prx/libSceSaveData.native/Export.cpp,core/libs/prx/libSceSaveData.native/SaveData.hppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me