google / ground-android

Ground mobile data collection app for Android
http://groundplatform.org
Apache License 2.0
245 stars 119 forks source link

Ghost-locks when moving the map and flickering "Add data collection site" card #2728

Open jo-spek opened 2 months ago

jo-spek commented 2 months ago

Relating partially to issue https://github.com/google/ground-android/issues/2727:

On my personal Android Device (Xiaomi Poco X3 NFC, Android 12 SKQ1.211019.001, GROUND build 0.1.9-openforis) in this survey, the map is randomly locked to the most recent place. Only when moving away and holding my finger on the touchscreen a little longer does the map move along and not jump back to the previous place. However, then the new place is sort of "ghost-locked". This makes sliding the map around for geolocation almost impossible. All the while, the "Add data collection site" card does randomly appear and disappear. See the video for better understanding.

The same did not happen on any other of my surveys, however, some of the 'smoothness' of gliding over the map is gone and there are frequent small 'jumpbacks' (for lack of a better word). They are only annoying and do not inhibit the work, but diminish the user experience.

https://github.com/user-attachments/assets/c6231977-8d52-4e56-8f1c-d0a1d18d895f

jo-spek commented 2 months ago

So I just figured this happens the further I am away from the "center of action", i.e. where most mapping takes place. I was on the survey that takes place in Ghana but was testing it in Germany where the app just wouldn't work.

Faking my GPS to be close to Kumasi, the survey worked just fine, but coming closer to the Côte d'Ivoire border the misbehavior started again.

gino-m commented 2 months ago

I verified that this is happening when new sites (LOI) are received from the server. Two primary issues to investigate:

jcqli commented 1 month ago

@shobhitagarwal1612 you were looking into the viewport, do you have any observations to add here?

shobhitagarwal1612 commented 1 month ago

I'm not sure why that is happening. Will try repro'ing it locally to understand what's happening under the hood

gino-m commented 1 month ago

I'm not sure why that is happening. Will try repro'ing it locally to understand what's happening under the hood

Sounds good. Be sure to try with dev Firebase and not local emu, since Cloud Messaging isn't supported there.

gino-m commented 6 days ago

Initial debugging reveals that GoogleMapsFragment.setFeatures() is called 5 times when an LOI is modified in the remote datastore:

2024-11-11 16:17:54.337  3951-3951  GoogleMapsFragment      com.google.android.ground            V  setFeatures() called with 5 features
2024-11-11 16:17:54.712  3951-3951  GoogleMapsFragment      com.google.android.ground            V  setFeatures() called with 5 features
2024-11-11 16:17:54.720  3951-3951  GoogleMapsFragment      com.google.android.ground            V  setFeatures() called with 5 features
2024-11-11 16:17:54.726  3951-3951  GoogleMapsFragment      com.google.android.ground            V  setFeatures() called with 6 features
2024-11-11 16:17:54.732  3951-3951  GoogleMapsFragment      com.google.android.ground            V  setFeatures() called with 6 features

While SurveyRepository.loadAndSyncSurveyWithRemote is called only once as expected. We may need to debounce or otherwise isolate changes to the local db to prevent the UI from getting thrashed.

gino-m commented 6 days ago

Just verified that this isn't occurring in the latest codebase. @jo-spek can you please re-open if this occurs again?

gino-m commented 1 day ago

I just observed this again at HEAD right after new LOIs were synced. It appears that as the UI catches up with newly synced remote changes the map gets forced back to the previous viewport. Probably related to #2831.