android icon indicating copy to clipboard operation
android copied to clipboard

Sync stops after Network switch

Open the-hotmann opened this issue 10 months ago • 7 comments

Describe the bug

When the network switches from WiFi to mobile while syncing, the syncing process will stop and needs to be manually started again to continue. This is not appreciated; it should resume automatically.

Steps to reproduce

  1. Start syncing.
  2. Switch networks.
  3. Realize it has stopped.

Expected behavior

If the network I switched to is set/allowed to sync, it should resume automatically.

Actual behavior

It stops and needs to be resumed manually.

$ /usr/bin/ocis version
Version: 5.1.0-prealpha+52b00b116
Compiled: 2024-04-10 00:00:00 +0000 UTC

the-hotmann avatar Apr 11 '24 02:04 the-hotmann

@TheOneRing @dragotin

can you help to gather the needed info? What could trigger that?

micbar avatar Apr 11 '24 18:04 micbar

@the-hotmann which client are you using?

TheOneRing avatar Apr 12 '24 08:04 TheOneRing

@micbar @TheOneRing thanks for the swift response!

I use the android client from the PlayStore in the latest version 4.2.1 (a41d1f917)

the-hotmann avatar Apr 12 '24 10:04 the-hotmann

Thanks for reporting, will take a look inside. Connection is detected as lost in the middle of network switching and not resumed. In fact, connections are only resumed in case of connection recovery after outage.

jesmrec avatar Apr 12 '24 11:04 jesmrec

@jesmrec you're welcome! Can you please leep this thread up-to-date and inform us about your findings and eventual changes?

Thanks in advance!

the-hotmann avatar Apr 13 '24 10:04 the-hotmann

Sure. At this point, we'll need to check how deep the changes would be... but it deserves a look.

jesmrec avatar Apr 15 '24 06:04 jesmrec

We have an operating system restriction that causes the worker to be relaunched when it meets the requirements it has. In our case, it has a restriction to only execute if there is an internet connection. When we switch connections (from Wi-Fi to cellular), the operating system decides if there is a violation of the worker’s rules, as it might interpret this specific situation as a loss of connection rather than a network change. In any case, it is something beyond our control as it depends on the operating system.

As a potential solution, we could include a manual retry in the worker’s catch block that only works when there is an active network and a NetworkErrorException has occurred. This way, when a network change occurs, the upload would be retried.

However, this would not completely solve the problem, as this condition might not be met for the following reason:

  • There is a network change, but the process was not fast enough for the network validation function to detect that a network is available. Therefore, it will detect that there is no connection. This issue is arbitrary because it depends on the speed at which the device connects to the network.

This possible solution would only work for workers: uploads and downloads. All other synchronization operations must be handled separately.

On the other hand, we have a problem with the download worker. When we lose the connection, we receive a NoNetworkConnectionException() error when we should receive a NetworkErrorException(). As a result, in this case, we cannot differentiate a priori whether the cause of the error was a server failure or a loss of connection.

Aitorbp avatar Sep 04 '24 11:09 Aitorbp