timetagger icon indicating copy to clipboard operation
timetagger copied to clipboard

Recording doesn't always stop

Open eldelacajita opened this issue 1 year ago • 2 comments

Lately I've been having this issue where I click "stop" and the recording does seem to stop, but when I come back to work I find the recording had actually not stopped and is still counting.

I don't know exactly how to reproduce it, but it happens quite frequently. I'm using TimeTagger on mobile as a pinned Firefox web app, and on my PC as a GNOME Web (Epiphany) web app, but the error doens't seem to depend on having both open at the same time.

Is this happening to anyone else?

eldelacajita avatar Jul 15 '22 07:07 eldelacajita

My first guess is that it might be related to the sync delay. When you make a change (e.g. stop a record) the sync indicator in the top left will show a plus (indicating pending changes). It will take 3 second or so before these changes are sent to the server. If you close the app before the sync takes place, the server wont receive it. On PC the sync still happens when you select another tab or application. I'm not sure whether this is also the case on mobile.

When the app is opened again later, the change should still show, and it should sync at that moment. But if you open the app on another device first, then that change will not be there (because it has not been sent to the server yet).

Could this explain the behavior that you're seeing?

almarklein avatar Jul 15 '22 11:07 almarklein

Thanks for the reply!

I'm pretty sure this happens even if I give the app enough time to sync to the server. From now on I'm always going to check if the app has synced before closing or opening it on another location, and I will see if the issue appears again.

eldelacajita avatar Jul 25 '22 18:07 eldelacajita

Any news on this? If not, I'll close the issue. You can then always re-open if you confirm this as a bug in the future. I also added a note related to this issue in ~#233~ #230.

almarklein avatar Sep 07 '22 11:09 almarklein

It seems that more carefully waiting for the sync indicator to finish its cycle fixed these issues. Basically, avoiding to stop a running task and immediately close the app. So yes, you can close this :+1:

eldelacajita avatar Sep 07 '22 11:09 eldelacajita

My apologies, I somehow failed to see what's actually happening earlier:

  1. you make a change, which is applied locally to the in-memory data structure.
  2. When the sync indicator is done, it will a. apply the change to the persistent browser database (indexedDB) b. try to send the changes to the server

So if you close the browser before the sync action is performed, you indeed lose these changes.

Browsers have an API to tell it that there is "unsaved data", so that the browser can open a popup when the tab is closed. We could probably use that here.

almarklein avatar Sep 12 '22 19:09 almarklein

Oh, interesting!

Is it possible to deliver a specific message with that popup? Maybe ask the user to just wait for some seconds for sync to finish, or something like that?

eldelacajita avatar Sep 12 '22 20:09 eldelacajita

Is it possible to deliver a specific message with that popup?

Yes, you can specify a custom message (and the PR does that), but all modern browsers chose to ignore it 🤷

almarklein avatar Sep 13 '22 06:09 almarklein

I guess in theory we could make the unload callback trigger something in the app, so that it's visible in addition to the popup ...

almarklein avatar Sep 13 '22 06:09 almarklein