fix(android): null-guard Player in Auth.onListen and getPlayerProfileImage - #249
Open
AbdullahGhanem wants to merge 1 commit into
Open
fix(android): null-guard Player in Auth.onListen and getPlayerProfileImage#249AbdullahGhanem wants to merge 1 commit into
AbdullahGhanem wants to merge 1 commit into
Conversation
…Image PlayersClient.currentPlayer can complete successfully with a null Player. onListen (used by GameAuth.player / isSignedIn) dereferenced it directly, crashing the app with a NullPointerException on the main thread. Report FailedToAuthenticate through the event sink instead, mirroring the guard already present in signIn().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PlayersClient.currentPlayercan complete successfully with a nullPlayer(seen in production on a Xiaomi Mi 10 Pro, games_services 5.0.0 and reproducible against currentdevelop).Auth.onListen— which backsGameAuth.playerand thereforeGameAuth.isSignedIn/GamesServices.isSignedIn— dereferences it immediately:Because this happens on the Android main thread inside a Task callback, a Dart-side
try/catcharoundisSignedIncannot catch it — the whole app crashes on what should be a harmless "are we signed in?" query.Fix
Apply the same guard
signIn()already has (added in 5.3.0) to the two remainingcurrentPlayersuccess listeners:onListen: emitFailedToAuthenticatethrough the event sink (Dart side then resolvesisSignedIntofalse).getPlayerProfileImage: returnFailedToGetPlayerProfileImage.9 lines, Android only, no API change.