1
\$\begingroup\$

I have been using Google Play Games Services (play-games-plugin for unity) for a while without problems. After a couple of recent changes I noticed that the plugin won't sync my saves anymore.

Trying to understand what happens I wrote my own method to resolve the conflict. However I came to find that it is not the conflict resolution that causes the problem. It's that the plugin keeps finding and resolving new conflicts!

It looks like the plugin keeps comparing new snapshots with the same old snapshot. It doesn't matter which one I accept, it will continue doing that. The most confusing part is that I don't even know where these new snapshots come from. I don't save the game every couple of seconds. In fact I didn't write or upload a single new save at these times! Also: How is it possible that they all have the exact same play time of 288.6303 seconds?

My debug log (full log on nopaste):

I/Unity   (10307): DEBUGLOG: SocialController: Started Loading Game Saves
I/Unity   (10307): DEBUGLOG: SocialController: Opening Save Game
I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict
I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict Inspecting Saves
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SocialController: Original 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Original 08/28/2016 15:08:23
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 09/07/2016 10:02:38
I/Unity   (10307): DEBUGLOG: SocialController: Keep Unmerged 09/07/2016 10:02:38

I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict
I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict Inspecting Saves
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SocialController: Original 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Original 08/28/2016 15:08:23
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 09/07/2016 10:02:52
I/Unity   (10307): DEBUGLOG: SocialController: Keep Unmerged 09/07/2016 10:02:52

I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict
I/Unity   (10307): DEBUGLOG: SocialController: Resolving Conflict Inspecting Saves
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SaveController: Deserializing SaveGame
I/Unity   (10307): DEBUGLOG: SocialController: Original 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 288.6303s
I/Unity   (10307): DEBUGLOG: SocialController: Original 08/28/2016 15:08:23
I/Unity   (10307): DEBUGLOG: SocialController: Unmerged 09/07/2016 10:03:08
I/Unity   (10307): DEBUGLOG: SocialController: Keep Unmerged 09/07/2016 10:03:08
...

My conflict resolution method (other methods on nopaste):

    void HandleConflict(IConflictResolver resolver, ISavedGameMetadata original, byte[] originalData, ISavedGameMetadata unmerged, byte[] unmergedData)
{
    if (originalData == null)
    {
        game.Log("SocialController: Resolving Conflict originalData == null");
        resolver.ChooseMetadata(unmerged);
    }
    else if (unmergedData == null)
    {
        game.Log("SocialController: Resolving Conflict unmergedData == null");
        resolver.ChooseMetadata(original);
    }
    else
    {
        game.Log("SocialController: Resolving Conflict Inspecting Save Data");
        SaveGame originalSave = SaveController.instance.DeserializeSaveGame(originalData);
        SaveGame unmergedSave = SaveController.instance.DeserializeSaveGame(unmergedData);
        game.Log("SocialController: Original " + originalSave.timePlayed + "s");
        game.Log("SocialController: Unmerged " + unmergedSave.timePlayed + "s");
        game.Log("SocialController: Original " + original.LastModifiedTimestamp);
        game.Log("SocialController: Unmerged " + unmerged.LastModifiedTimestamp);

        if (originalSave.timePlayed > unmergedSave.timePlayed)
        {
            game.Log("SocialController: Keep Original " + originalSave.timePlayed + "s");
            resolver.ChooseMetadata(original);
        }
        else if (originalSave.timePlayed < unmergedSave.timePlayed)
        {
            game.Log("SocialController: Keep Unmerged " + unmergedSave.timePlayed + "s");
            resolver.ChooseMetadata(unmerged);
        }
        else if (original.LastModifiedTimestamp >= unmerged.LastModifiedTimestamp)
        {
            game.Log("SocialController: Keep Original " + original.LastModifiedTimestamp);
            resolver.ChooseMetadata(original);
        }
        else
        {
            game.Log("SocialController: Keep Unmerged " + unmerged.LastModifiedTimestamp);
            resolver.ChooseMetadata(unmerged);
        }
    }
}

What is going on here?

\$\endgroup\$
  • \$\begingroup\$ I don't work with Google play's services, but I'm assuming you already did standard troubleshooting? (Refreshing the service, reinstalling?) \$\endgroup\$ – GMR516 Sep 7 '16 at 16:42
  • \$\begingroup\$ Yeah, I did all that... and now I deleted my saves on the cloud (which where from 08/27/2016 at 20:40 oddly enough). \$\endgroup\$ – Jan Sep 8 '16 at 11:50
  • \$\begingroup\$ (I pressed enter on accident and took to long to edit, so I had to split my comment) ...using ShowSelectSavedGameUI. What happened was that the original save from 08/28/2016 15:08:23 disappeared and after a couple of new conflicts from today (no idea where they came from, because I didn't do anything) the syncing process completed! I even got all my previous progress even though I deleted it on the cloud. Still no idea how and why this happened, or what to implement to solve this for players, but at least it has stopped on my device... \$\endgroup\$ – Jan Sep 8 '16 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.