none
Creators Program Unity Xbox Live Storage example failing?

    Question

  • I'm trying to hook up storage in my Creators Program game, and I'm trying out the GameSaveExample Unity scene that is from the GameSave.unitypackage (which is itself inside the XboxLive.unitypackage, which I downloaded from https://github.com/Microsoft/xbox-live-unity-plugin/releases).

    When I build the Unity example into a UWP application and then compile and run the UWP from my local computer (making sure the generated UWP application and my computer are both using the set up sandbox), the app throws an exception right after successfully signing in my Xbox Live account:

    System.ArgumentException occurred
      HResult=0x80070057
      Message=Value does not fall within the expected range.
      Source=<Cannot evaluate the exception source>
      StackTrace:
    <Cannot evaluate the exception stack trace>

    'XboxLiveStorageTest.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'C:\Users\Michael\Documents\Unity\XboxLiveStorageTest\Build\XboxLiveStorageTest\bin\x64\Debug\AppX\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

    Exception thrown: 'System.ArgumentException' in Assembly-CSharp.dll

    GameSaveHelper.Initialize Error: System.ArgumentException: Value does not fall within the expected range.

       at Windows.Gaming.XboxLive.Storage.GameSaveProvider.GetForUserAsync(User user, String serviceConfigId)

       at Microsoft.Xbox.Services.ConnectedStorage.GameSaveHelper.<Initialize>d__2.MoveNext()


    It looks like the following line in GameSaveHelper's Initialize method is failing because xboxLiveUser.WindowsSystemUser is null:

    var initTask = GameSaveProvider.GetForUserAsync(xboxLiveUser.WindowsSystemUser, configId).AsTask();

    The same thing seems to be occurring when I compile the UWP and run it on the console.  The app just stops at showing "Initializing save system...".

    Should this example be working?

    Console OS Version 10.16299.5090

    Windows OS Version 1709 (16299.125)

    Unity Version: 5.6.4f1

    VS Version: 15.4.1

    Thursday, January 25, 2018 6:47 AM

Answers

  • As a (temporary) workaround, I was able to use some code from another game save example (https://github.com/Microsoft/xbox-live-samples/tree/master/Samples/ID%40XboxSDK/GameSave):

                // Getting a GameSaveProvider requires the Windows user object. It will automatically get the correct provider for the current Xbox Live user.
                var users = await Windows.System.User.FindAllAsync();
                if (users.Count > 0)
                {
                    var configId = XboxLive.Instance.AppConfig.ServiceConfigurationId;
    
                    // OLD
                    GameSaveProviderGetResult result = await GameSaveProvider.GetForUserAsync(users[0], configId);
    
                    //// NEW (but not currently working)
                    //GameSaveProviderGetResult result = await GameSaveProvider.GetForUserAsync(SignedInUser.WindowsSystemUser, configId).AsTask();
    
                    if (result.Status == GameSaveErrorStatus.Ok)
                    {
                        _saveProvider = result.Value;
                        return true;
                    }
    
                    return false;
                }
                else
                {
                    Debug.LogError("Initialize Error: No Windows users found when creating save provider.");
                    return false;
                }
    

    • Marked as answer by Mike Palotas Thursday, May 03, 2018 6:28 AM
    Monday, January 29, 2018 3:44 AM
  • While re-importing the package, did you also remember to re-import the GameSave sub-package? The new GameSave code doesn't use SignedInUser.

    Instead, you'll notice that in GameSaveUI, it now uses:

    this.xboxLiveUser = SignInManager.Instance.GetPlayer(this.PlayerNumber);
                if (this.xboxLiveUser != null && this.xboxLiveUser.IsSignedIn)
                {
                    this.InitializeSaveSystem();
                }
                else
                {
                    SignInManager.Instance.OnPlayerSignIn(this.PlayerNumber, this.OnPlayerSignIn);
                    SignInManager.Instance.OnPlayerSignOut(this.PlayerNumber, this.OnPlayerSignOut);
                }

    And then in GameSaveHelper:

     var initTask = GameSaveProvider.GetForUserAsync(xboxLiveUser.WindowsSystemUser, configId).AsTask();
    It basically is using the new SignInManager to retrieve info about the user.

    • Marked as answer by Mike Palotas Thursday, May 03, 2018 6:28 AM
    Wednesday, May 02, 2018 5:36 PM

All replies

  • Hi Mike,

    Usually I've seen this happen if you're missing: "Xbox Live Platform Extensions SDK" from: http://aka.ms/xblextsdk

    Do you know if this has been installed?

    Thursday, January 25, 2018 6:24 PM
  • I installed the SDK before I tried working with the storage functionality.

    I used the link (http://aka.ms/xblextsdk, which looks like the same as yours) from this page:

    https://docs.microsoft.com/en-us/windows/uwp/xbox-live/get-started-with-creators/configure-xbox-live-in-unity

    The downloaded file gave me three versions (10240, 14393, and 15063), and I installed 15063 because it was the closest to my OS version (16299).

    I can try installing a different version if you think it might help-

    Thanks!

    Thursday, January 25, 2018 6:45 PM
  • Hi Mike,

    Our team is investigating this issue and we will let you know what we find once we have more information.

    Kam Woo - Xbox Live Forum Moderator

    Friday, January 26, 2018 4:53 PM
    Moderator
  • As a (temporary) workaround, I was able to use some code from another game save example (https://github.com/Microsoft/xbox-live-samples/tree/master/Samples/ID%40XboxSDK/GameSave):

                // Getting a GameSaveProvider requires the Windows user object. It will automatically get the correct provider for the current Xbox Live user.
                var users = await Windows.System.User.FindAllAsync();
                if (users.Count > 0)
                {
                    var configId = XboxLive.Instance.AppConfig.ServiceConfigurationId;
    
                    // OLD
                    GameSaveProviderGetResult result = await GameSaveProvider.GetForUserAsync(users[0], configId);
    
                    //// NEW (but not currently working)
                    //GameSaveProviderGetResult result = await GameSaveProvider.GetForUserAsync(SignedInUser.WindowsSystemUser, configId).AsTask();
    
                    if (result.Status == GameSaveErrorStatus.Ok)
                    {
                        _saveProvider = result.Value;
                        return true;
                    }
    
                    return false;
                }
                else
                {
                    Debug.LogError("Initialize Error: No Windows users found when creating save provider.");
                    return false;
                }
    

    • Marked as answer by Mike Palotas Thursday, May 03, 2018 6:28 AM
    Monday, January 29, 2018 3:44 AM
  • Hi Mike,

    The latest release of the Xbox Live Unity Plugin (v1804) just went out and should have your problem fixed: https://github.com/Microsoft/xbox-live-unity-plugin/releases/tag/v1804

    Thank you for your patience and hope this resolves your issues :) 


    Wednesday, May 02, 2018 1:06 AM
  • I updated to the new plugin (https://github.com/Microsoft/xbox-live-unity-plugin/releases/tag/v1804) by downloading and importing the XboxLive.unitypackage.  I'm assuming that should have properly updated everything?  I didn't have any compilation issues moving from the older 1711 release.

    Starting with the same code as my post above, I tried using the new way of getting a save provider:

    GameSaveProviderGetResult result = await GameSaveProvider.GetForUserAsync(SignedInUser.WindowsSystemUser, configId).AsTask();

    However, SignedInUser.WindowsSystemUser was still null.

    Is this still an expected way of getting the user?  How can I be sure that I properly upgraded my Xbox Live package?  I'm still seeing all the same issues as I did with the 1711 release (especially the error when trying to load save data after resuming from game suspension).


    Wednesday, May 02, 2018 6:44 AM
  • While re-importing the package, did you also remember to re-import the GameSave sub-package? The new GameSave code doesn't use SignedInUser.

    Instead, you'll notice that in GameSaveUI, it now uses:

    this.xboxLiveUser = SignInManager.Instance.GetPlayer(this.PlayerNumber);
                if (this.xboxLiveUser != null && this.xboxLiveUser.IsSignedIn)
                {
                    this.InitializeSaveSystem();
                }
                else
                {
                    SignInManager.Instance.OnPlayerSignIn(this.PlayerNumber, this.OnPlayerSignIn);
                    SignInManager.Instance.OnPlayerSignOut(this.PlayerNumber, this.OnPlayerSignOut);
                }

    And then in GameSaveHelper:

     var initTask = GameSaveProvider.GetForUserAsync(xboxLiveUser.WindowsSystemUser, configId).AsTask();
    It basically is using the new SignInManager to retrieve info about the user.

    • Marked as answer by Mike Palotas Thursday, May 03, 2018 6:28 AM
    Wednesday, May 02, 2018 5:36 PM
  • Ah, yeah--forgot there was a package inside the package.

    Since the new release does sign in/game save differently, we can probably consider the bug fixed (or not applicable anymore) by moving to 1804.  People using the 1711 release can use the workaround I posted above.

    Thanks

    Thursday, May 03, 2018 6:28 AM