Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a SaveGame file on iOS occasionally gets stuck indefinitely #163

Open
dev-kasibhatla opened this issue Jun 27, 2024 · 5 comments
Open
Assignees

Comments

@dev-kasibhatla
Copy link

Flutter version 3.22.2 (stable)
games_services: 4.0.1
iOS 16.5.1

Game center sign in and cloud saves are functioning as expected on iOS. I only run SaveGame methods after a successful sign in. But in about one in 30 launches

String data = (await SaveGame.loadGame(name: CloudSaveKey.slot1.name)) ?? '';

will get stuck indefinitely, with no error thrown, no logs for me to inspect.

I've tried checking all logs on the iPhone's console, restarting the app, restarting the phone in such a case. There's unfortunately not much I can do to debug this further.
The only thing that seems to fix this right now is reinstalling the app.

My current workaround is to wait 5 secs for response otherwise proceed assuming an empty response.

Any help appreciated :)

@Abedalkareem
Copy link
Owner

Hi @dev-kasibhatla

I'm looking at the code, I don't see a path where we don't return result, if we get error we return an error, if we get result we return the results.
Any way I added debug prints to the code and it will be in the next release which will help us know where it's failing.
#164

    currentPlayer.fetchSavedGames(completionHandler: { savedGames, error in
      guard error == nil else {
        result(error?.flutterError(code: .failedToLoadGame))
        return
      }
      
      guard let item = savedGames?
        .first(where: { $0.name == name }) else {
        result(PluginError.failedToLoadGame.flutterError())
        return
      }
      item.loadData { data, error in
        guard let data = data, error == nil else {
          result(error?.flutterError(code: .failedToLoadGame))
          return
        }
        let string = String(data: data, encoding: String.Encoding.utf8)
        result(string)
      }
    })

@Abedalkareem Abedalkareem self-assigned this Aug 8, 2024
@Abedalkareem
Copy link
Owner

Hi @dev-kasibhatla

Can you use version 4.0.2 and share the logs?

@thize
Copy link

thize commented Sep 6, 2024

For me, the first session always crashes indefinitely, but it works normally from the second session onwards.

@dev-kasibhatla
Copy link
Author

Hi @Abedalkareem, sorry I've been busy and my temporary workaround is doing fine
I'll still run some tests this weekend and get back.

@thize seems to be able to reproduce it reliably. Can you please share logs like @Abedalkareem asked?

@theLee3
Copy link
Collaborator

theLee3 commented Oct 29, 2024

I have been unable to reproduce the issue. The only thing I can track down is a duplicate signIn call never returning. If you are calling signIn prior to loading the save and are already authenticated, then the signIn call would never return, and thus, your loadGame call would never be reached.

If you are still experiencing or can recreate the issue, please try the same code after pulling the potential hotfix to see if it resolves your problem. Update your pubspec.yaml with the following:

games_services: # 4.0.3
  git:
    url: https://github.com/Abedalkareem/games_services.git
    ref: gc-duplicate-sign-in-fix
    path: games_services

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants