Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kyzominskiy opened this issue Oct 25, 2019 · 2 comments · May be fixed by #400
Open

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

kyzominskiy opened this issue Oct 25, 2019 · 2 comments · May be fixed by #400

Comments

@kyzominskiy
Copy link

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

@cytim
Copy link

cytim commented Sep 7, 2021

Related to #170

@cytim
Copy link

cytim commented Sep 7, 2021

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 cytim linked a pull request Sep 12, 2021 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants