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

Bug Report: Timer stops when computer goes to sleep #84

Closed
moltar opened this issue Jun 17, 2020 · 18 comments
Closed

Bug Report: Timer stops when computer goes to sleep #84

moltar opened this issue Jun 17, 2020 · 18 comments
Labels
enhancement New feature or request

Comments

@moltar
Copy link

moltar commented Jun 17, 2020

Describe the bug

Timer stops working when computer goes to sleep.

To Reproduce

  1. Start timer.
  2. Close computer lid
  3. Wait 2 minutes
  4. Open lid and wait for computer to wake up
  5. Observe timer had not subtracted 2 minutes, and it is currently stopped (not counting).

Expected behavior

Timer continues counting after re-opening of the computer.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Version: 10.15.4 (19E287)

Additional context

This feature is mostly important for break timers. When I am on a 15 minute break, the computer may fall asleep.

@roldanjr
Copy link
Member

Describe the bug

Timer stops working when computer goes to sleep.

To Reproduce

  1. Start timer.
  2. Close computer lid
  3. Wait 2 minutes
  4. Open lid and wait for computer to wake up
  5. Observe timer had not subtracted 2 minutes, and it is currently stopped (not counting).

Expected behavior

Timer continues counting after re-opening of the computer.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: macOS Catalina
  • Version: 10.15.4 (19E287)

Additional context

This feature is mostly important for break timers. When I am on a 15 minute break, the computer may fall asleep.

I've also encountered that and I have no idea how to prevent Operating System to not fall asleep while timer still running.

Anyway thanks for informing me. I will try to fix that ASAP on my next release.

@moltar
Copy link
Author

moltar commented Jun 17, 2020

I think the solution would be not to store the remaining seconds, but rather store the start date, and then calculate the remaining time based on that.

@roldanjr
Copy link
Member

I'm not that good enough to comprehend what do you mean by that. If possible can you provide some good example on how to do that?

@roldanjr
Copy link
Member

I have tried the PowerSaveBlocker of Electron preventing the Operating System from entering sleep mode before but it didn't work on my Laptop.

@moltar
Copy link
Author

moltar commented Jun 17, 2020

I am not sure how the app works. But I am assuming there is a sort of thing:

let remainingSeconds = 100

setInterval(() => remainingSeconds = remainingSeconds - 1, 1000)

But instead, should be something like:

const timeStartDate = new Date()
const timerDurationMs = 15 * 60 * 1000
let remainingTime = 0

setInterval(() => {
  remainingTime = timerDurationMs - (new Date().getTime() - timeStartDate.getTime())
}), 1000)

That way, the hard date is saved, and it can always be referenced again.

But maybe this is already how it works, I am not sure.

@moltar
Copy link
Author

moltar commented Jun 17, 2020

Then probably want an event like resume when it comes back from sleep to fire of the timers in the UI again:

https://www.electronjs.org/docs/api/power-monitor

@roldanjr
Copy link
Member

I am not sure how the app works. But I am assuming there is a sort of thing:

let remainingSeconds = 100

setInterval(() => remainingSeconds = remainingSeconds - 1, 1000)

But instead, should be something like:

const timeStartDate = new Date()
const timerDurationMs = 15 * 60 * 1000
let remainingTime = 0

setInterval(() => {
  remainingTime = timerDurationMs - (new Date().getTime() - timeStartDate.getTime())
}), 1000)

That way, the hard date is saved, and it can always be referenced again.

But maybe this is already how it works, I am not sure.

Does it prevent the Operating System from asleep?

@roldanjr
Copy link
Member

roldanjr commented Jun 17, 2020

Then probably want an event like resume when it comes back from sleep to fire of the timers in the UI again:

https://www.electronjs.org/docs/api/power-monitor

I've also tried it before and it didn't work. I will try it again combining powerMonitor and PowerSaveBlocker with the latest Electron release.

@roldanjr roldanjr added the enhancement New feature or request label Jun 17, 2020
@moltar
Copy link
Author

moltar commented Jun 17, 2020

Does it prevent the Operating System from asleep?

Not, but it will re-start from the right time if it wakes up at least.

Otherwise the time is frozen at the time when the system went to sleep.

@roldanjr
Copy link
Member

I'm working with the new features of the app right now and will try to fix some bugs including the issue you've posted. I really appreciate your suggestion and will try it if my solutions didn't fix the issue at least.

@roldanjr
Copy link
Member

Hi @moltar . I just released new version of the app.

Please visit v2.10.0-beta Release Note.
Also, let me know if the bug you've encountered fixed by this latest version of the app. Have a great day!

@moltar
Copy link
Author

moltar commented Jun 20, 2020

Ok, thanks. Upgraded, will try next week.

@moltar
Copy link
Author

moltar commented Jun 20, 2020

Got the following immediately after launching the upgraded version:

image

And I can't quit the app now.

@moltar
Copy link
Author

moltar commented Jun 20, 2020

The window is squished:

image

@roldanjr
Copy link
Member

@moltar just go to Settings and just press Restore Default.

It might happened due to old settings are not compatible with the new features.

Please let me know the results.

@moltar
Copy link
Author

moltar commented Jun 21, 2020

just go to Settings and just press Restore Default.

That did fix it, thanks.

@moltar
Copy link
Author

moltar commented Jul 15, 2020

I think this is still an issue.

I just had a 5 minute timer go off. Full screen.
I closed the lid.
10 minutes passed
I opened the lid, and the timer was still at 4 minutes.

@roldanjr
Copy link
Member

I'm sorry @moltar but I think it is not an issue.

Just don't closed the lid or manually sleep the computer because the app doesn't have the full control to prevent you from making your computer off / sleep. The only concern here is that the app will prevent your computer from automatically sleeping while your computer is on idle especially when full-screen persisted and preventing you from working.

If you really want to take that break. I suggest just don't close the lid. Just wait for the break to finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants