Loading data from a GKSavedGame fails when multiples devices are involved

I've integrated cloud saves into my game and they work perfectly when a single device is involved. However, if I modify a save on another device then attempting to continue the save on the original device fails in GKSavedGame.loadData. Generally it fails with an error of

The requested operations could not be completed because one or more parameters are invalid.


Ocassionally I get the error that "<filename>.bundle doesn't exist" as well. I fetch the saves through `fetchSavedGames` and then resolve any conflicts by choosing the save with the most recent modification data, loading its data and then calling `resolveConflictingSavedGames'. However, I'm not actually getting any conflicts when the above error happens. Additionally, my saves actually consist of several files which need to be loaded. However, which file fails seems to be random.


This is my loading code. I'm calling this function from C#, hence the code to deal with marshaling data.


@_cdecl("_gameKitSavedGameLoadData")
func _gameKitSavedGameLoadData(handle: UInt, csave: CSGKSavedGame) {
  let save = Unmanaged.fromOpaque(csave).takeUnretainedValue()
  save.loadData { data, err in
  if err != nil {
  let errString = "_gameKitSavedGameLoadData: for \(save.name ?? "")" + err!.localizedDescription
  errString.withCString { ptr in
  SaveCallbacks.loadSavedGameDataFailure?(handle, ptr)
  }
  return
  }
   
  let buffer = UnsafeMutablePointer.allocate(capacity: data!.count)
  data!.copyBytes(to: buffer, count: data!.count)
  SaveCallbacks.loadSavedGameDataSuccess?(handle, buffer, data!.count)
  }
}

The error about paramaters being invalid strikes me as particularly odd given that the only parameter that `GKSavedGame.loadData` has is a closure that is getting invoked and can't be invalid. I've also looked at the documentation and haven't seen any reference to the possibility of the GKSavedGame object being invalid. I thought that it could be my marshaling code as well, but the GKSavedGame object that this code deals with looks exactly as I expect it to. It has a vaild name, device name and modification date.

  • Hello,

    I was wondering if you ever found a solution for this. I am encountering the same problem.

    I get that same error "The requested operations could not be completed because one or more parameters are invalid." when I try to resolve conflicts.

Add a Comment