SimpleMobileTools / Simple-Calendar

A simple calendar with events, tasks, customizable colors, widgets and no ads.
https://www.simplemobiletools.com
GNU General Public License v3.0
3.54k stars 1.15k forks source link

CalDAV calendars not refreshed unless I launch Google's app! #1389

Open llevrel opened 3 years ago

llevrel commented 3 years ago

This is Simple Calendar v 6.13.7 Pro, from F-droid. My setup is like this:

When I add an event to the server with Evolution, then synchronize the phone with DAVx5, then hit the synchronization menu entry in Simple Calendar, the new event doesn't show up. At this moment, if I open the stock Android calendar app, the event is there, and back to Simple Calendar it suddenly appears!

(The comment dated Jul 7, 2020 in bug #921 reports a very similar problem.)

When I installed Simple Calendar I faced something similar. I had installed and synched DAVx5 beforehand. In Simple Calendar I activated CalDAV in settings, turned on all calendars, synched... no effect! I was getting crazy but it finally worked by re-synching DAVx5 although there were no new events to synch from the server.

Last word: I had been using Simple Calendar for ~6 months already (can't remember which version) and was so happy with it that I thought "now I can disable the stock Android app". Rebooted my phone and... it didn't boot anymore! I had to factory-reset it... What an irony!

llevrel commented 3 years ago

Some testing.

First test:

  1. stop Google Agenda and Simple Calendar in Settings > Apps
  2. launch DAVx5 synch, wait until it finishes
  3. launch Simple Calendar, launch synch: I get the "Synch in progress" info-balloon, but it never finishes (I can wait many minutes and nothing happens)
  4. launch again DAVx5 synch (although no new event on the server), I quickly get SC's "Synch completed" info-balloon, although it's still in background (the message displays on top of DAVx5)

Second test: Same as first, except SC is not stopped at step 1. It seems the problem is the same. ("seems" because I tried only once)

Third test: Steps 1-3 same as first, but

  1. launch Google Agenda. The events are correct there. The synch in SC is still pending, until I launch DAVx5 synch. So here Google Agenda seems not to help. /or/
  2. launch Google Agenda. Launch DAVx5 synch, wait for it to complete. Then launch SC and synch: the synch will eventually complete; it seems to take a bit of time. Maybe Google Agenda is somehow fiddling with the event database?

The first test is reliable, I reproduced it several times. The other tests have been tried only once. Let me know if I can help more. Thanks!

iansangines commented 3 years ago

Same problem here!

The only thing that works for me for the sync is unselecting and selecting my CalDav calendar in "Settings -> CALDAV -> Manage synced calendars" option. Then, the "Syncing.." and "Sync completed" toasts appears. There is no other way to sync it successfully.

I hope it helps on the bug research and let me know if i can help too!

TheShanMan commented 2 years ago

Same here. Very unintuitive to have to turn the calendars on in a caldav section when I don't want to use Simple Calendar caldav functionality (I'm using davx5 too). Glad I found this bug though. Otherwise I don't know if I would've figured it out.

ltguillaume commented 2 years ago

+1

llevrel commented 2 years ago

Same here. Very unintuitive to have to turn the calendars on in a caldav section when I don't want to use Simple Calendar caldav functionality (I'm using davx5 too). Glad I found this bug though. Otherwise I don't know if I would've figured it out.

AFAIK, SC doesn't do what DAVx5 does. DAVx5 synchronises the so-called Calendar Storage in your phone with some server. SC's "CalDAV" functionality consists in using the phone's Calendar Storage. I guess it's called CalDAV as a shorthand, but the Calendar Storage contents may come to the phone by any means, CalDAV or not (e.g. Google calendars are there too). See https://www.davx5.com/manual/_images/how_davx5_interacts_with_other_components.png

@TheShanMan @ltGuillaume did you try and run my tests?

ltguillaume commented 2 years ago

@llevrel That all isn't applicable for me, for the following reasons:

  1. I don't have "Google Calendar" installed.
  2. I did try Etar and the calendar app on a LG G7:
naveensingh commented 2 years ago

@llevrel I'm trying to reproduce the first test:

  1. Install DAVx5 and add a calendar "Personal"
  2. Enable the "Personal" calendar in SC's settings
  3. Sync in DAVx5 and then in SC, everything works and the events are there.
  4. Force stop Google Calendar & SC
  5. Add a new event on the server
  6. Sync in DAVx5
  7. Open SC and refresh, the new event is there without any delay

Am I doing something wrong?

llevrel commented 2 years ago

@llevrel I'm trying to reproduce the first test:

  1. Install DAVx5 and add a calendar "Personal"
  2. Enable the "Personal" calendar in SC's settings
  3. Sync in DAVx5 and then in SC, everything works and the events are there.
  4. Force stop Google Calendar & SC
  5. Add a new event on the server
  6. Sync in DAVx5
  7. Open SC and refresh, the new event is there without any delay

Am I doing something wrong?

Seems no. What version do you use? The bug may have been corrected...

ltguillaume commented 2 years ago

I've found it to be device specific, or perhaps just Android version specific as to whether it works or not. Either way, it is definitely not fixed yet.

naveensingh commented 2 years ago

@llevrel @ltGuillaume

I'm on the latest version but I'll try with the older version you mentioned.

Q. What devices you guys are using?

I'm interested in the installed OS. Is it MIUI, Funtouch OS or something like that (heavily skinned)?

llevrel commented 2 years ago

Q. What devices you guys are using?

I'm interested in the installed OS. Is it MIUI, Funtouch OS or something like that (heavily skinned)?

This is a vanilla Android 8.1.0 (phone is "echo Feeling", kind of noname) with stock Google apps.

TheShanMan commented 2 years ago

FWIW (you didn't ask me but maybe it's helpful info), I have a moto g7 with rooted lineageos 19.1 (android 12) and microg (no gapps).

naveensingh commented 2 years ago

thanks to y'all I was able to reproduce this bug on a somewhat old device with Android 9 (MIUI 11), the bug indeed is device/ROM specific

I will share a test APK once I have a fix :+1:

naveensingh commented 2 years ago

AFAIK, SC doesn't do what DAVx5 does. DAVx5 synchronises the so-called Calendar Storage in your phone with some server. SC's "CalDAV" functionality consists in using the phone's Calendar Storage.

True. Simple calendar can only fetch what is already there in the android calendar database (which isn't working properly) and request sync adapters (DAVx5, Google calendar) to update the database with new events from the server. SC can't really fetch events from the server itself, a working (not force stopped) sync adapter service must be there for CalDAV synchronization to work properly.

naveensingh commented 2 years ago

If anyone's up for testing here's a test APK that should fix this issue

ltguillaume commented 2 years ago

Just tried this build. It seems to just fail to trigger a sync by DAVx5 when I use the menu item to do so, even though the toast messages state sync started/finished. Only from within DAVx5 I can reliably trigger a sync.

But I also started to see this behavior in Etar all of a sudden. It might be related to DAVx5 then, even though it did work on other devices. I suppose I'll have to dig into DAVx5 logs and/or logcat when I have time...

naveensingh commented 2 years ago

Hi! @ltGuillaume

As mentioned before, a working (not stopped) sync adapter service must be there for CalDAV synchronization to work properly. It's possible that the device (ROM) you are on has a battery saver feature that is restricting this background invocation

ltguillaume commented 2 years ago

@Naveen3Singh DAVx5 is excluded from that...

ltguillaume commented 1 year ago

I see the same issues on an Android 13 device. How can I help to solve this issue once and for all? A calendar app with unreliable synchronization is a calendar app that will be uninstalled by many.

naveensingh commented 1 year ago

@ltguillaume

Hi!

(This is a quick reply, I'll be back later)

What device are you using now? Can you reproduce it reliably? During my tests, when events aren't refreshed in SC, they aren't refreshed in Etar either. Can you check and confirm (again) that Etar is working and SC is not with your new device? (A recording would be nice)

Thanks for tagging those related issues.

ltguillaume commented 1 year ago

Not my devices, so it will take some time before I have another example. I've stopped using SC altogether, primarily because of all the sync issues.

ltguillaume commented 1 year ago

But isn't there a debug version I could run, so I can provide you with some proper information, other than just saying "yeah it still won't work properly here, even though other calendar apps are working fine"?

Or would there be anything I can logcat?

naveensingh commented 1 year ago

I'll send you a debug build with toasts and some log statements so we can check what triggered and what didn't.

naveensingh commented 1 year ago

Alright, here's an APK: https://github.com/naveensingh/Simple-Calendar/releases/download/test_caldav_sync/calendar-prepaid-debug.apk

How to test:

  1. Install the APK from the link above
  2. Enable CalDAV sync and refresh CalDAV calendars from the options menu.
  3. Once the sync is finished, create a new calendar event in your other remote client (say Google's calendar on the web)
  4. In the simple calendar, again trigger CalDAV refresh once or twice and wait for the sync to finish.
  5. If the new event is nowhere to be found, go to some other calendar app where sync is known to work properly (Etar?) and trigger a sync there, and wait for the sync to finish. Check if the new event is available there now (this is important).
  6. Reopen Simple Calendar and check if the new event is available now.

Once the issue is successfully reproduced (steps 5 and 6), from the options menu, tap on "Share logs" and share it here or send it to me directly (just select your email client when sharing). Note that the logs might expose your synchronized email and CalDAV calendars.

(Like before, I can reliably reproduce THIS issue with Simple Calendar but I can reliably reproduce it with other calendars too on a Samsung with Android 13. Events aren't refreshed in any of my calendar apps unless I trigger a refresh in Google's Calendar app)

Note: This does not include any fixes or changes other than a few logs and toasts to address this issue. The APK is compiled against this branch on my fork.