How the state machine works
Game Saves uses an internal state machine to coordinate UI callbacks with the async operation lifecycle. When a UI callback fires, the async operation pauses—theXAsyncBlock callback doesn’t fire until the callback is resolved. The state machine doesn’t progress until the game calls the corresponding response API or the async operation is canceled.
This means:
- Each callback type has a corresponding response API. Call the response API to tell the system what to do next.
- Response APIs can be called inside or outside the callback function.
- If a response action is
Retry, the operation retries and may trigger the same callback again. - The
XAsyncBlockcallback only fires once the operation reaches a terminal state—success, cancellation, or an offline fallback.
PFGameSaveFilesUiSyncFailedCallbackfires with the error.- The
XAsyncBlockcallback doesn’t fire yet—the state machine waits for a response. - If the user selects
Retryand the retry also fails, the sync failed callback fires again. - If the user selects
Cancel, theXAsyncBlockcallback fires withE_PF_GAMESAVE_USER_CANCELLED. - If a retry succeeds, the
XAsyncBlockcallback fires withS_OK.
When callbacks trigger
UI callbacks only fire during two async operations:Registering callbacks
Register all callbacks before callingPFGameSaveFilesAddUserWithUiAsync or PFGameSaveFilesUploadWithUiAsync:
Callback reference
Progress
Reports upload or download progress. UsePFGameSaveFilesUiProgressGetProgress inside the callback to retrieve the current PFGameSaveFilesSyncState, bytes completed, and bytes total.
Callback: PFGameSaveFilesUiProgressCallback
Response API: PFGameSaveFilesSetUiProgressResponse
The progress callback doesn’t require a response to continue—the operation keeps progressing on its own. Only call the response API if the user wants to cancel.
Sync states
ThePFGameSaveFilesSyncState enum indicates which phase the operation is in:
Sync failed
Fires when a sync operation fails, for example due to network issues or rate limits. Callback:PFGameSaveFilesUiSyncFailedCallback
Parameters: Receives PFGameSaveFilesSyncState (the phase that failed) and HRESULT (the error code).
Response API: PFGameSaveFilesSetUiSyncFailedResponse
For more details on offline mode behavior, see Game Saves offline mode.
Active device contention
Fires duringPFGameSaveFilesAddUserWithUiAsync when another device is already the active device for this user. The callback receives PFGameSaveDescriptor structs for both the local and remote save data, which include device names, timestamps, and save sizes that you can display to help the user decide.
Callback: PFGameSaveFilesUiActiveDeviceContentionCallback
Response API: PFGameSaveFilesSetUiActiveDeviceContentionResponse
For more details on active device behavior, see Game Saves active device changes.
Conflict
Fires duringPFGameSaveFilesAddUserWithUiAsync when local and cloud save data have diverged. The callback receives PFGameSaveDescriptor structs for both the local and remote save data.
Callback: PFGameSaveFilesUiConflictCallback
Response API: PFGameSaveFilesSetUiConflictResponse
Conflict resolution applies to the entire save, not individual files or folders. For details on how conflicts are detected at the atomic unit level and resolved globally, see Game Saves conflicts.
Out of storage
Fires duringPFGameSaveFilesAddUserWithUiAsync when the local device doesn’t have enough disk space to download save data from the cloud. The callback receives requiredBytes indicating how much space is needed.
Callback: PFGameSaveFilesUiOutOfStorageCallback
Response API: PFGameSaveFilesSetUiOutOfStorageResponse
Platform requirements
For Steam Deck implementation details, see Steam Deck implementation guide.
