Repository navigation
Cloud saves: ask the player which save wins, and wait for a listed iCloud save to download - #2180
Closed
kendrasloane90 wants to merge 1 commit into
Closed
kendrasloane90 wants to merge 1 commit into
kendrasloane90 wants to merge 1 commit into
Conversation
…loud save to download
Both launchers read the cloud's save before Play. When the save changed on both this device and the cloud, they show both with their dates and device and set DM_SAVE_SYNC_CHOICE from the player's pick, instead of the newer file date winning. A save started fresh a minute after a real one has the later date and none of the progress: on Cadence of Hyrule the phone's new slot, saved 45 s after the Mac's, replaced a 54-minute save in the cloud, which survived only in the phone's save-backups. The second symptom is iCloud: a save it has only listed (.save.dmsync.icloud) could come back empty from the coordinated read, so the first start played this device's save and the second, after the download landed, brought the cloud's in.
dm/host/save_sync.{h,c}: save_sync_report() answers one key=value line about both saves (hash, newest date, file count, device), the sync base and whether both changed, fetching the cloud's save through the same front-end call the mount uses; dm_save_sync_title_id() gives a launcher the title ID the host was built for. FETCH_MS 10 s -> 20 s, since what it waits on is an iCloud download.
dm/ios/Sources/SaveSync.m: front_save_sync_fetch asks for a save iCloud has only listed and waits up to 25 s for the file itself before the coordinated read, logging how long it took; a read that still fails stays -1, which the host treats as unreadable (it plays this device's save and sends nothing), so a slow iCloud never replaces the cloud's progress.
dm/ios/Sources/Launcher.swift and dm/mac/Launcher.swift: the report runs off the main thread when Play is pressed; on a conflict a confirmationDialog (iPhone) or an NSAlert (Mac) offers this device's save, the cloud's, or Cancel, and sets DM_SAVE_SYNC_CHOICE=local:<hash> or cloud:<hash>; with no conflict it sets ask. A report that could not be read leaves the choice unset, because ask without a comparison keeps the cloud's save out of the session. Both read DM_SAVE with getenv: ProcessInfo's environment is a snapshot from before env.txt and the saved choices are applied. The iPhone shows "Checking the cloud save…" while the report waits.
dm/host/tests/t_save_sync.c: section 15, the report's states (nothing anywhere, only here, in step, only in the cloud, both changed with the cloud's date newer, the cloud unreadable, sync off).
Front-ends: new: save_sync_report(save, cloud_file, title, out, n) and dm_save_sync_title_id() in dm/host/save_sync.h — the line a launcher reads to ask before it starts the game
Front-ends: interface: DM_SAVE_SYNC_CHOICE=ask must be set only after a successful report; set blind, it keeps the cloud's save out of the session and sends nothing
Checked: make -C dm/host/tests GAME=0100000000010000 run (all pass; save sync 96 checks, metadata 41); Cadence of Hyrule 01000B900D8B0000 1.5.0 on an iPhone (iPhone19,4) and a Mac mini M2 Pro, macOS 26.6: both saves' dates shown on Play, the cloud choice brought the Mac's save in and the phone's was kept in save-backups, and a start with no conflict played as before. The iCloud wait was checked with a planted .save.dmsync.icloud in a scratch folder (DM_LAUNCHER=0): the host gave up at 20 s, the front end at 25 s, nothing written.
kendrasloane90
force-pushed
the
pr/cloud-save-choice
branch
from
November 10, 2026 14:21
8fe1be0 to
bb88fcf
Compare
seedds
added a commit
that referenced
this pull request
Nov 11, 2026
…and wait for a cloud save iCloud has only listed: with both saves changed since the last sync, the host kept the one with the newest file date, so a new game's first save written 45 s after a 54-minute save replaced it in the cloud (Cadence of Hyrule, 01000B900D8B0000 1.5.0, an iPhone and a Mac mini M2 Pro; the real save survived only in the phone's save-backups/<date> cloud). The host could ask instead (ss_decide's SS_ASK, DM_SAVE_SYNC_CHOICE in docs/frontends.md), but neither launcher set it. Now save_sync_report(save, title, folder, wait_ms, out, n) answers, before the start, one line about the two saves as the game's first mount will see them: hashes, dates, file counts, sizes (ss_meta.bytes), the cloud's device and whether both changed. It finds the cloud's file with the mount's own rules (cloud_path: DM_SAVE_SYNC, icloud, a folder named after the game) and fetches it through the same front-end call, into a file of its own under <save>.sync-tmp. Both launchers call it at Play through SaveSyncReport.swift (shared; pack_app.py builds it into the Mac launcher): on a conflict they show both saves with their date and size, since the newer is not always the one with progress (no default button on the Mac), and pass local:<hash> or cloud:<hash>; with nothing to choose, ask; a cloud save that did not come in a minute is said so, with this device's save (offline: the mount does not wait again), another try or Cancel; while it downloads, Play Without It goes on at once. The Mac launcher sets DM_SAVE before its window (launcher.c set it after, so the check could not read the save) and checks with the window off too; the iPhone launcher names the cloud file with dm_save_title() (hle_fs.c) and DM_SAVE_SYNC from dm_cloud_saves_env(). On the iPhone, front_save_sync_fetch asks iCloud for a save it has only listed and waits for the file until it is there or NSURLUbiquitousItemDownloadingErrorKey reports a failure, so an offline fetch ends at once; a refused request falls through to the coordinated read as before. The mount's own wait stays 10 s. With no launcher (DM_LAUNCHER=0, an iPhone app without launcher.json) the newer save still wins. The diagnosis, the report and the launcher prompts are PR #2180's; changed here: the report finds the cloud file itself (the PR's launchers built the path, which missed the game's own folder and icloud: such a start passed ask with nothing compared and synced neither side from then on), the Mac's DM_SAVE order (its prompt never showed), sizes in the dialog, offline instead of ask when the cloud was not read (the PR's start waited 20 s in the report and 20 s more at the mount), the download wait stopping on iCloud's error, the shared Swift file; the PR's iOS folder picker rewrite is left out (issue #1148, its own change). Reference entries: Both saves changed is the player's choice, not the newest file's; The cloud's save is listed but not downloaded. Checked: t_save_sync 101 checks (section 15: nothing anywhere, a save only here, in step, the game's own folder, only in the cloud, both changed with the new save the newer and the smaller, the cloud unreadable, sync off, DM_SAVE_SYNC when no folder is given, nothing left behind), t_save_sync_metadata 41, t_fs 146, test_docs, test_nsp_mac_app, test_launcher_storage; the Mac launcher compiles and links as pack_app.py builds it, the iPhone's Swift sources and SaveSync.m compile against the iOS SDK; lint_c.py tidy on the changed C files: nothing above the baseline. Not run: either dialog by hand, an iPhone (a listed save, an offline start, a reconnect), regress.py (no route turns cloud saves on). lint_python.py's one new finding is dmsh_entry.py's, on main before this Front-ends: new: save_sync_report(save, title, folder, wait_ms, out, n) and dm_save_title() in dm/host/save_sync.h, the comparison a launcher asks the player with before the start Front-ends: interface: pass DM_SAVE_SYNC_CHOICE=ask only after a comparison; with the cloud not read, offline Co-authored-by: kendrasloane90 <257330740+kendrasloane90@users.noreply.github.com>
Owner
|
Thank you: the diagnosis was right, and the fix is on main as 07d6ea4, with you as co-author. Main already had the machinery to ask the player ( What changed from this PR:
Not checked here, and still open: an iPhone run (a save iCloud has only listed, an offline start, a reconnect) and both dialogs by hand. If you can sideload main and try those on your phone and Mac, your |
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Two ways a cloud save was silently ignored, both found playing Cadence of Hyrule (a save on the iPhone and one on a Mac, sync through iCloud Drive).
1. Both changed, and the newer file date won. A save started fresh on one device a minute after the other device's real save has the later date and none of the progress. That is what happened: the phone's brand-new slot (4.2 KB,
playTimeSeconds=0, saved 45 s after the Mac's) beat a 54-minute, 5-heart save and replaced it in the cloud; the real save survived only insave-backups/<date> cloud. The host already hadDM_SAVE_SYNC_CHOICE=askandss_decidereturnsSS_ASKfor exactly this state, but no front end ever set it, so the player was never told what had been chosen for them.2. A save iCloud has only listed was read as empty. iCloud keeps
save.dmsyncas.save.dmsync.iclouduntil something asks for it, and the coordinated read can come back with nothing before the download lands. Result: the first start played this device's save, the download finished while the game was open, and the second start brought the cloud's save in — "start it, force quit it, start again".The change:
dm/host/save_sync.{h,c}—save_sync_report(save, cloud_file, title, out, n)answers one line about both saves:cloud=<-1|0|1> local=<hash|-> saved=<date> files=<n> chash=<hash|-> csaved=<date> cfiles=<n> cdevice=<host> sametitle=<0|1> conflict=<0|1>, fetched through the samefront_save_sync_fetchthe mount uses (so an iCloud item that is only listed downloads first), decided withss_decide(..., ask=1). Plusdm_save_sync_title_id(), since the Mac launcher buildssave_sync.cwith no profile header.FETCH_MS10 s → 20 s, because what it waits on is an iCloud download.dm/ios/Sources/SaveSync.m—front_save_sync_fetchasks for a listed-but-absent file and waits up to 25 s for the file itself before the coordinated read, loggingthe cloud's save downloaded in N s. A read that still fails stays-1(unreadable), which the host treats as "play this device's and send nothing" — a slow iCloud can never replace the cloud's progress.dm/ios/Sources/Launcher.swift,dm/mac/Launcher.swift— the report runs off the main thread when Play is pressed. Onconflict=1aconfirmationDialog(iPhone) or anNSAlert(Mac) offers this device's save, the cloud's save (with both dates and the other device's name), or Cancel; the pick setsDM_SAVE_SYNC_CHOICE=local:<hash>/cloud:<hash>. With no conflict the launcher setsask. A report that could not be read leaves the variable unset —askwithout a comparison stops every mount from replacing either side, which is how the first version of this patch turned a failed comparison into "it didn't pick up the newer cloud save". Both readDM_SAVEwithgetenv:ProcessInfo.environmentis a snapshot from beforemain.mappliesenv.txt, so the report silently returned nil on the Mac.dm/host/tests/t_save_sync.c— section 15: the report's states (nothing anywhere, only here, in step, only in the cloud, both changed with the cloud's date newer, the cloud unreadable, sync off).Checked
make -C dm/host/tests GAME=0100000000010000 run— all pass;t_save_sync96 checks, 0 failed,t_save_sync_metadata41 checks, 0 failed. The save-sync target was also run in a clean worktree of this branch alone.01000B900D8B00001.5.0 (update 458752, 4 DLC), 60 fps with no dropped frames in 300. What was compared: the launcher'slauncher: save sync: …line againstDocuments/save/save.syncon the phone, the dialog's two dates against both saves' mtimes, and the cloud file's hash after each choice.save-backups/<date> local.launcher: no conflict; playing)..save.dmsync.icloudin a scratch cloud folder withDM_LAUNCHER=0: the host gives up atthe cloud's save did not come within 20 s, the front end logsstill downloading after 25 s, and nothing is written to either side. The successful-download path (downloaded in N s) was seen on a real iCloud fetch.iPhone19,4, iOS 26) and Mac mini M2 Pro (macOS 26.6); the host tests also run on a Mac mini M1, macOS 27.2.Front ends
Front-ends: new: save_sync_report(save, cloud_file, title, out, n)anddm_save_sync_title_id()indm/host/save_sync.h— the line a launcher reads to ask before it starts the game.Front-ends: interface: DM_SAVE_SYNC_CHOICE=askmust be set only after a successful report; set blind it keeps the cloud's save out of the session and sends nothing.Docs
docs/reference/services.md: two entries under File system and save data ("Both saves changed is the player's choice, not the newest file's", "The cloud's save is listed but not downloaded"), andpython3 dm/tools/docs_symptoms.pywas run.