marinara icon indicating copy to clipboard operation
marinara copied to clipboard

Timer doesn't work when mac goes into sleep mode (Worked fine previously)

Open kyzominskiy opened this issue 4 years ago • 2 comments

Hello! I did found that the Marinara Chrome extension is sticking when mac goes to sleep mode. I am using this extension more than one month and it's never happen to me previously. This week I did examined it at first.

The timer goes as usual when I turn on timer brake countdown, but when mac goes to sleep mode, there is no any sound that says I need to start focusing. And I make my mac waked up and I see now that timer is stick on number that it had when mac got to sleep.

There is a video that I captured to show how it happens:

I didn't update my laptop and nothing is changed in my routine at all. The timer worked fine and always did let me know that the brake is finished till my mac sleeps, but this week something is happen and it sticks

kyzominskiy avatar Oct 25 '19 18:10 kyzominskiy

Related to #170

cytim avatar Sep 07 '21 15:09 cytim

I started using this great extension recently and ran into the same problem. I conducted a test to find the root cause. A proposal is included in the last section. Hope that we could solve this. 👀

Test

  1. Add log when the timer tick and expire.
  2. Set the focus time to be 5 minutes (for testing purpose).
  3. Start the timer.
  4. Lock the computer.
  5. Unlock the computer some time later.

Here's the result.

tick 1 2021-09-07T15:13:30.192Z
tick 2 2021-09-07T15:14:31.194Z
tick 3 2021-09-07T15:15:31.201Z
tick 4 2021-09-07T15:21:55.490Z
tick 5 2021-09-07T15:22:55.569Z
expired 2021-09-07T15:23:19.574Z

Interpretation

  • The computer slept at around 15:15, and woke up at around 15:21.
  • The tickInterval and expireTimeout was paused when the computer was asleep.
  • The tickInterval and expireTimeout was resumed when the computer woke up, but they were not aware of the paused period.

Proposal

Instead of using ticketInterval and expireTimeout, we can create a single setInterval that runs every second to compare checkpointStartAt to track the time. This way the timer can tick/expire correctly as soon as the script resumes from sleep mode.

I could submit a PR to demonstrate. 🙏🏽

cytim avatar Sep 07 '21 15:09 cytim