digidem / comapeo-mobile

The next version of Mapeo mobile
GNU General Public License v3.0
5 stars 1 forks source link

Autostop sync #561

Open gmaclennan opened 3 months ago

gmaclennan commented 3 months ago

Is your feature request related to a problem? Please describe.

Currently, once a user has started syncing, and sync completes, the only way to stop syncing with any additional devices is to navigate away from the sync screen.

Example workflow:

  1. Devices A & B start syncing with each other
  2. Sync between devices A & B completes
  3. Device A remains on the sync screen (which says "done")
  4. Device C connects to the same Wifi and starts syncing
  5. Device A will start syncing with C

Users may find this behaviour unexpected. This becomes a bigger issue if we do not stop sync when the user navigates away from the sync screen (see #560), because there is then no way for the user to ever stop syncing.

Describe the solution you'd like

Syncing should stop after a timeout has elapsed from when syncing is complete.

The timeout is important because sync can be fast, and if it stops as soon as it completes it can restrict the ability of others to also sync. Example scenario:

  1. Device A, B & C want to sync and are connected
  2. Devices A & B press sync first, and their sync completes
  3. Device C presses sync after devices A & B complete sync
  4. Device C should expect to be able to sync with A & B if they press sync within a fixed interval from when A & B started or finished syncing.

I think a timeout of 2-5 minutes should be sufficient for other devices to join the "sync party". From the users perspective: anyone wanting to join a sync party needs to start syncing within 2-5 minutes of each other.

I think this will also require additional UX to enable users to manually stop syncing before the timeout. Currently the user can only stop sync before sync is complete, but when sync is complete, there is no way to stop it.

Describe alternatives you've considered

The current implementation (continue syncing until the user navigates away from the screen) is ok for now, since this issue will only affect users who remain on the sync screen after sync has complete and unexpected sync with additional devices.

Once #560 has been addressed, this issue will become more pressing.

Design tasks

Coding tasks

achou11 commented 3 months ago

I think a timeout of 2-5 minutes should be sufficient for other devices to join the "sync party". I think maybe the timeout should start when sync starts, rather than when it finishes.

just for clarity, are you suggesting that this timeout should be handled client-side? the sync start method exposes an option for a timeout, but I believe it's applied to when you're no longer receiving new data

https://github.com/digidem/mapeo-core-next/blob/3ac3f65a5e6deb808c35dc0bf9c1dbac2a5da218/src/sync/sync-api.js#L247

achou11 commented 3 months ago

Syncing should stop after a timeout has elapsed from when syncing is complete.

ah missed this initial note, although this seems to somewhat conflict with the previous one I referred to 🤔

gmaclennan commented 3 months ago

My apologies, I have edited my comment about the timeout being from when sync starts.

Thanks for the share to the sync.start() method - I got caught be my browser autocompleting to a previous commit of mapeo-core-next and I couldn't find that autostopDataSyncAfter method.

I've refined the issue to be specific about the tech tasks.