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

thaliMobile's use of setInterval will kill our battery dead #697

Closed
yaronyg opened this issue Apr 1, 2016 · 2 comments
Closed

thaliMobile's use of setInterval will kill our battery dead #697

yaronyg opened this issue Apr 1, 2016 · 2 comments
Assignees
Labels
bug
Milestone

Comments

@yaronyg
Copy link
Member

@yaronyg yaronyg commented Apr 1, 2016

Right now in thaliMobile there is a function called peerAvailabilityWatcher that runs on a regular interval (currently every second) and it checks to see if we have any really old peer availability announcements that need to be cleaned up. But this means that the device cannot ever really go to sleep as it will keep waking up every second! This is an awesome way to obliterate battery.

Thankfully the fix is pretty easy. We just need to calculate when the next entry is supposed to expire and set our timer for that long. Once we have no entries left then we don't set any timer at all. Once we get notified of a new peer event and enter it into peerAvailabilities then we set a new timer.

@yaronyg
Copy link
Member Author

@yaronyg yaronyg commented Aug 11, 2016

The issues are fixed. But tests aren't passing in CI.But it doesn't appear to be our test.

@artemjackson
Copy link
Contributor

@artemjackson artemjackson commented Aug 11, 2016

@yaronyg so could we close this issue?

@yaronyg yaronyg closed this Aug 11, 2016
@yaronyg yaronyg added 4 - Done and removed 3 - Working labels Aug 11, 2016
artemjackson added a commit that referenced this issue Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.