XGameSaveInitializeProvider hangs

2026-10-13T17:52:16.7166667+00:00

Hello Xbox team,

We frequently experience a problem when calling XGameSaveInitializeProvider. The application hangs on this call for 30 seconds (we then have to terminate the application because we don't have the means to handle this stall).

We want to address this issue to give players a good experience, but we cannot understand what could be causing this hang. Can it be a network connection issue? We use XNetworkingGetConnectivityHint before calling XGameSaveInitializeProvider, but maybe the issue arises in between these two calls.

We want to use XGameSaveInitializeProviderAsync for asynchronous provider initialization and cancel the request, because the current call hangs for too long. But will XAsyncCancel work for XGameSaveInitializeProviderAsync, because the documentation says that XAsyncCancel is not guaranteed to occur at all for some operations?

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Bruno Caetano de Brito 490 Reputation points
    2026-10-18T00:12:06.0633333+00:00

    Hello Maksim,

    Here is what the official GDK documentation says, with recommendations.

    1) Why the call can block for a long time

    XGameSaveInitializeProvider does more than create a handle. When the provider initializes, the title tries to acquire the lock on the user’s cloud save storage and sync the player’s saves (XGameSave API overview). Its reference page states that it can block and may show UI to the user while saves are synchronized. For that reason it should not be called on the UI thread or on a time-sensitive thread (XGameSaveInitializeProvider – Remarks).

    So yes, network conditions can cause the delay. A XNetworkingGetConnectivityHint check made just before the call doesn’t guarantee that the sync will be fast: connectivity can change, and the service can still be slow to respond. If you initialize with syncOnDemand = true, the docs also note that container access is impossible when the device is offline or has connectivity issues, and that sync progress UI may appear.

    2) Can you rely on XAsyncCancel?

    Not as your main protection. The XAsyncCancel documentation says cancellation may happen synchronously, asynchronously, or not at all, depending on the call being canceled. The XGameSaveInitializeProviderAsync page does not say whether this specific operation honors cancellation. Treat it as best-effort:

    • Call XAsyncCancel if you want to, but design your game to stay correct even if the operation keeps running.
    • If cancellation does take effect, XGameSaveInitializeProviderResult returns E_ABORT, and your completion callback still runs. Free your context there, and only there.

    3) Recommended design

    1. Switch to XGameSaveInitializeProviderAsync. The official sample notes that it can be started even from a time-sensitive thread, because the work and the callback run on platform threads. Your game loop keeps running, so there is nothing to terminate.
    2. Use your own timeout at the game level, not cancellation. If initialization hasn’t completed after N seconds, show a “Syncing saves…” state, or let the player continue offline if your design allows it. The overview says that when the cloud sync fails because of connection loss, the title should decide whether users can keep playing in offline mode.
    3. Handle every failure HRESULT in the completion callback, and retry the initialization later if needed.
    4. Close the provider with XGameSaveCloseProvider when the title suspends or terminates. The provider can’t be reused across suspend/resume, so re-initialize it after resume.

    Also note that Microsoft now recommends XGameSaveFiles for new GDK titles, with XGameSave used only when XGameSaveFiles isn’t an option. The two can’t be mixed in the same title.

    To narrow down the root cause, please share:

    • The platform (PC or console) and GDK version.
    • The syncOnDemand value you pass.
    • Whether any sync UI appears during the 30 seconds.
    • Whether the hang happens mostly on first launch, after switching devices, or after resuming.

    The lock and sync behavior depends on these details.

    Hope this helps. If it does, please consider accepting the answer.Hello Maksim,

    Here is what the official GDK documentation says, with recommendations.

    1) Why the call can block for a long time

    XGameSaveInitializeProvider does more than create a handle. When the provider initializes, the title tries to acquire the lock on the user’s cloud save storage and sync the player’s saves (XGameSave API overview). Its reference page states that it can block and may show UI to the user while saves are synchronized. For that reason it should not be called on the UI thread or on a time-sensitive thread (XGameSaveInitializeProvider – Remarks).

    So yes, network conditions can cause the delay. A XNetworkingGetConnectivityHint check made just before the call doesn’t guarantee that the sync will be fast: connectivity can change, and the service can still be slow to respond. If you initialize with syncOnDemand = true, the docs also note that container access is impossible when the device is offline or has connectivity issues, and that sync progress UI may appear.

    2) Can you rely on XAsyncCancel?

    Not as your main protection. The XAsyncCancel documentation says cancellation may happen synchronously, asynchronously, or not at all, depending on the call being canceled. The XGameSaveInitializeProviderAsync page does not say whether this specific operation honors cancellation. Treat it as best-effort:

    • Call XAsyncCancel if you want to, but design your game to stay correct even if the operation keeps running.
    • If cancellation does take effect, XGameSaveInitializeProviderResult returns E_ABORT, and your completion callback still runs. Free your context there, and only there.

    3) Recommended design

    1. Switch to XGameSaveInitializeProviderAsync. The official sample notes that it can be started even from a time-sensitive thread, because the work and the callback run on platform threads. Your game loop keeps running, so there is nothing to terminate.
    2. Use your own timeout at the game level, not cancellation. If initialization hasn’t completed after N seconds, show a “Syncing saves…” state, or let the player continue offline if your design allows it. The overview says that when the cloud sync fails because of connection loss, the title should decide whether users can keep playing in offline mode.
    3. Handle every failure HRESULT in the completion callback, and retry the initialization later if needed.
    4. Close the provider with XGameSaveCloseProvider when the title suspends or terminates. The provider can’t be reused across suspend/resume, so re-initialize it after resume.

    Also note that Microsoft now recommends XGameSaveFiles for new GDK titles, with XGameSave used only when XGameSaveFiles isn’t an option. The two can’t be mixed in the same title.

    To narrow down the root cause, please share:

    • The platform (PC or console) and GDK version.
    • The syncOnDemand value you pass.
    • Whether any sync UI appears during the 30 seconds.
    • Whether the hang happens mostly on first launch, after switching devices, or after resuming.

    The lock and sync behavior depends on these details.

    Hope this helps. If it does, please consider accepting the answer.

    Fontes:

    Was this answer helpful?

    2 people found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.