playgameservices / android-basic-samples

Google Play game services - Android samples
Apache License 2.0
970 stars 972 forks source link

SnapshotClient : weird conflicts on open() #305

Closed caroparo closed 2 years ago

caroparo commented 4 years ago

I've been getting a lot of conflicts when using SnapshotClient.open() on one single AVD device.

I'm building with: Android Studio 3.5.3 Android SDK 29, minSDK 16, target SDK 29 NDK 21.0.6113669

play-services-games:19.0.0 play-services-auth:17.0.0

The Android Emulator I used is version 29.3.4 from Android Studio, Pixel 3 (5.46", 1080x2160, 440dpi, selected from default device definition list) running Nougat (API Level 25 Android 7.1.1 x86 image with Google Play, selected from recommended system image list).

I had set the device Location to Taiwan to match my location; also had to set the system TimeZone manually to GMT+8 since somehow it won't detect correctly. System time is correct once the timezone is set correctly.

I have made sure that latest Google Play Games is installed (release date Feb 2, 2020), and my Google Play Services is up-to-date (checked by clicking "extended controls" on said AVD, it brought up Google Play Store with no "update" option).

With all these, and one single commitAndClose from one device, the following open will cause a conflict. The conflicting snapshots basically have the same contents, with only LastModifiedTimestamp being the difference. It seems to me that SnapshotsClient somehow did not treat local cache and retrieved cloud data as sync even if they actually are the same, causing continuous conflicts when resolveConflict.

Downgrading to play-services-games:18.0.0 seems to relieve this issue from taking 5-10 resolveConflict retries to taking 1 resolveConflict, but I still find it weird.

I'm using 4G-LTE mobile network as a shared wifi in my work environment; not sure if that affects anything.

caroparo commented 4 years ago

I'm now pretty sure downgrading to play-services-games:18.0.0 did not help. I'm facing infinite conflicts when signing in to another virtual device, very similar to what's described in the 2016 issue thread.

My emulator's google play services version is: 20.04.14(040700-294335909) Google Play Games: 2020.01.15709(292726199.292726199-000708) Play Store: 18.6.43-all [0] [PR] 293212862

This device's locale is zh-TW, for what it's worth.

caroparo commented 4 years ago

The root cause of my issue seems to be that I was incorrectly relying on use of SnapshotMetadataChange.Builder.fromMetadata() to copy my old metadata when committing changes. Noticeably, getDeviceName from corrupted metadata had returned wrong names, sometimes null, and other times commits from my emulators were recorded as my physical device (dumped from commitAndClose results).

That said, I don't know whether the Android Emulator update and some auto-starting background Google Play services update in my emulator I saw in these two days had anything to do with disappearance of the issue I saw.

smile616 commented 2 years ago

not reproducible anymore, closing.