larkery / orgcal

Android calendar <-> org mode
15 stars 1 forks source link

Testing does not result in visible calendar events #2

Closed novoid closed 2 years ago

novoid commented 2 years ago

Hi,

After reading about the release in #1, I tried to set it up:

  1. Creating a new directory in a Syncthing share between my computer and my Google Pixel 4a.
  2. Copying two of my Orgdown files that contain lots of headings with some having active timestamps. (For testing, I don't want to use my original Org files for the moment.)
  3. Installing the apk on the mobile.
  4. Choosing the folder of the Orgdown files to be indexed. (no contacts file)
  5. What dates to use: Active timestamps
  6. Invoking a manual sync.

When I understood it correctly, my Android calendar should show me the timestamps. It doesn't. Do I have to add an additional calendar source? I haven't found any showing up in the calendar app.

Thanks for your help!

larkery commented 2 years ago

I don't know what orgdown is.

I did fix a bug so there is an updated apk, which might work.

Beyond that I am not sure what to suggest. Maybe try a single, simple org file that has one thing in like

* an event
<2022-07-20>

and see if that works.

novoid commented 2 years ago

Orgdown is the name of the syntax of org-mode: https://karl-voit.at/2021/11/27/orgdown/ and https://gitlab.com/publicvoit/orgdown

After updating the APK with the 2nd release, I noticed that I've got a new "Org Agenda" section in Google Calendar on my mobile with a checkbox per Orgdown file in the configured orgcal directory. This might be related to the fact that I shut down my phone during night. Maybe the change was caused by the reboot, independent of the APK upgrade. However, this is progress.

Whatever I do, when I switch to orgcal, I always get "Last sync at [yesterday evening]" and not any time today. I switched to one minimal Orgdown file with the simple content you suggested and Sync frequency = manual. Still, "Sync now" doesn't give any feedback and switching back and forth to orgcal still gives me "Last sync at [yesterday evening]". At least the minimal file should be parsed rather quickly. Maybe the job is still running in background from before the switch from the large Orgdown files to the tiny one?

Could it be an issue when I don't specify a "Contacts file"?

novoid commented 2 years ago

Update: I re-checked and found the test event from above on my Android calendar. The "Last sync at" message now contains a time-stamp from today.

It seems to be the case that the parsing and updating takes rather long. Now that I know that it basically works, I try to extend to the test directory with the small test file that works and two large Orgdown files with many many entries. I'll report back here.

larkery commented 2 years ago

The other possibility is that something about your org files makes it crash - the parser should be reasonably robust but I only use it on a limited set of files that have headings, scheduled dates, properties, tags, and sometimes some text in the body.

My agenda files have about a thousand headings in them to parse and it takes less than a second.

I guess it could also be if your org files have loads of text in that it has to skip through, that might be slow. The parsing looks ahead for an ugly regex to find the next thing it's interested in, and that might be expensive for your files.

larkery commented 2 years ago

If you know how to use logcat you can look in the logs and see whether there's some exception I'm not catching; I didn't do any work to make it robust or produce any good error messages or anything so it just silently falls over if something unexpected happens.

I usually debug this by plugging it in and running it under the debugger.

novoid commented 2 years ago

I've installed a Logcat reader app. It requires some permissions set via adb. Unfortunately, my adb doesn't show me my Pixel 4a somehow. From a quick research I guess it requires some Linux USB device settings. I'll need to investigate that issue further.

larkery commented 2 years ago

What you want is probably to install the android tools on your workstation so you have adb, then turn on dev mode on your phone, enable usb debugging, plug it in and do adb connect, then adb logcat should let you watch the logs.

Most phones make a lot of logs but you can redirect into a file and try to find what's useful.

novoid commented 2 years ago

OK, I've registered my Android device and now I'm able to access logs via Android app as well as via adb - thanks for the tip.

After re-invoking a manual scan grep -A 1 "CALSYNC" logcat_07-14-2022_18-05-01.txt shows:

[07-14 18:03:21.971 26445:26493 I/ORGSYNC/CALSYNC]
Perform sync content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
--
[07-14 18:03:21.971 26445:26493 I/ORGSYNC/CALSYNC]
Starting sync of content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
--
[07-14 18:03:22.042 26445:26493 I/ORGSYNC/CALSYNC]
Parsingandroid.support.v4.provider.TreeDocumentFile@bc1b362

So nothing unusual in my opinion.

Update: Via "adb log" and grep ORGSYNC 2022-07-14T18.08.02_logcat.log

07-14 18:07:39.742 17785 17785 I ORGSYNC : Request calendar sync
07-14 18:08:15.230 17785 17785 I ORGSYNC : Request calendar sync
07-14 18:12:45.454 26445 26493 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@bc1b362 contains 4955 headings
07-14 18:12:45.454 26445 26493 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@43b9db0
07-14 18:12:45.505 26445 26493 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@43b9db0 contains 1 headings
07-14 18:12:45.505 26445 26493 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@5ed6cf3
07-14 18:15:40.468 26445 26493 I ORGSYNC/CALSYNC: Create: DONE ...
07-14 18:15:40.469 26445 26493 I ORGSYNC/CALSYNC: Create: DONE [#A] ...                                                                
07-14 18:15:40.469 26445 26493 I ORGSYNC/CALSYNC: Create: DONE ...                                                                         
07-14 18:15:40.469 26445 26493 I ORGSYNC/CALSYNC: Create: STARTED ...                                                                                                
07-14 18:15:40.469 26445 26493 I ORGSYNC/CALSYNC: Create: DONE [12/12] ...
[...]
07-14 18:15:40.552 26445 26493 I ORGSYNC/CALSYNC: Create: Christmas 2018
07-14 18:15:40.660 26445 26493 I ORGSYNC/CALSYNC: 0 edits to android.support.v4.provider.TreeDocumentFile@bc1b362, and 0 to append
07-14 18:15:40.661 26445 26493 I ORGSYNC/CALSYNC: 0 edits to android.support.v4.provider.TreeDocumentFile@43b9db0, and 0 to append
07-14 18:15:40.690 26445 26493 I ORGSYNC/CALSYNC: 0 edits to android.support.v4.provider.TreeDocumentFile@5ed6cf3, and 0 to append
07-14 18:15:40.690 26445 26493 I ORGSYNC/CALSYNC: Applying 457 operations
07-14 18:15:43.519 26445 26493 I ORGSYNC/CALSYNC: Done
07-14 18:16:24.679 26445 28833 I ORGSYNC/CALSYNC: Perform sync content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:16:24.679 26445 28833 I ORGSYNC/CALSYNC: Starting sync of content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:16:24.748 26445 28833 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@47e545e
07-14 18:25:24.858 26445 28833 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@47e545e contains 4955 headings
07-14 18:25:24.858 26445 28833 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@9e93d0c
07-14 18:25:24.888 26445 28833 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@9e93d0c contains 1 headings
07-14 18:25:24.888 26445 28833 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@632c03f
07-14 18:28:22.788 26445 28833 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@632c03f contains 3298 headings
07-14 18:28:23.512 17785 17785 I ORGSYNC/FILEJOBSERVICE: Agenda sync triggered!
07-14 18:28:23.522 17785 17785 I ORGSYNC : Request calendar sync
07-14 18:28:23.629 17785 17785 I ORGSYNC/FILEJOBSERVICE: Watching 3 contenturi for 0 files...
07-14 18:28:23.710 29593 29593 I ORGSYNC/FILEJOBSERVICE: Watching 3 contenturi for 0 files...
07-14 18:28:23.727 29593 29610 I ORGSYNC/CALSYNC: Perform sync content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:28:23.727 29593 29610 I ORGSYNC/CALSYNC: Starting sync of content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:28:23.798 29593 29610 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@bc1b362
07-14 18:37:17.031 29593 29610 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@bc1b362 contains 4955 headings
07-14 18:37:17.031 29593 29610 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@43b9db0
07-14 18:37:17.104 29593 29610 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@43b9db0 contains 1 headings
07-14 18:37:17.104 29593 29610 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@5ed6cf3
07-14 18:44:19.300 29593 29610 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@5ed6cf3 contains 3298 headings
07-14 18:44:19.998 17785 17785 I ORGSYNC/FILEJOBSERVICE: Agenda sync triggered!
07-14 18:44:20.004 17785 17785 I ORGSYNC : Request calendar sync
07-14 18:44:20.881 17785 17785 I ORGSYNC/FILEJOBSERVICE: Watching 3 contenturi for 0 files...
07-14 18:44:20.909 30211 30211 I ORGSYNC/FILEJOBSERVICE: Watching 3 contenturi for 0 files...
07-14 18:44:20.926 30211 30231 I ORGSYNC/CALSYNC: Perform sync content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:44:20.926 30211 30231 I ORGSYNC/CALSYNC: Starting sync of content://com.android.externalstorage.documents/tree/primary%3Avk%2F2del%2F2022-07-13-orgcal-tests
07-14 18:44:21.810 30211 30231 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@bc1b362
07-14 18:53:16.992 30211 30231 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@bc1b362 contains 4955 headings
07-14 18:53:16.992 30211 30231 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@43b9db0
07-14 18:53:17.044 30211 30231 I ORGSYNC/CALSYNC: android.support.v4.provider.TreeDocumentFile@43b9db0 contains 1 headings
07-14 18:53:17.044 30211 30231 I ORGSYNC/CALSYNC: Parsingandroid.support.v4.provider.TreeDocumentFile@5ed6cf3

Woah, now it's working out fine. However, it seems to be a performance issue after all if you consider the timestamps here.

First entries are visible in my Android calendar.

Currently, I do have 3 files. The minimal one from above (1 entry), my misc.org with 3333 headings and 67k lines and my business.org with 5018 headings and 118k lines. Not all headings do have active time-stamps. Almost all do have inactive time-stamps at least in the property drawer (I do log created, state changes, and closing timestamps).

novoid commented 2 years ago

@larkery As you can see in the log output above, there are multiple "Request calendar sync" entries although I've set the update frequency to manual and I did not invoke a manual sync after 18:08 so far.

Is this a bug or did I misunderstand the concept? Maybe changes from the Android calendar to the Orgdown files are polled independent from the sync interval which is only scanning for changes in the Orgdown files?

I modified one Android calendar entry at around 18:30. Since then, I did not observe any change in the Orgdown file. I guess the Orgdown file gets modified after the next manual sync invocation? (at 19:00 I manually invoked a sync to see if the Orgdown file gets changed now.)

larkery commented 2 years ago

Not sure why that would happen; it might be that I try and trigger a sync when you open the app or something. I've tidied up the logging a bit to say the cause when it tries to force a sync.

The parser is pretty slow but it'd be more work than I want to do to make it fast or to replace it with someone else's logic.