You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setupUI calls refresh. refresh set a timer to call setupUI every 1 second.
This resulted infinite loop.
At midnight this gets worst, because date changes, which will trigger calculatePrayerTimes and calculatePrayerTimes also calls setupUI...
Multiple infinite loops explains cpu spike at midnight.
Fix
Replaced refresh with a function startUpdateTimer that run once per second.
Added updateCountdown checks if day changed and recalculate prayer times at midnight.
UI will only be built when needed instead of every second
This is a regex-based check for API usage that can pose security, performance or
maintainability issues, or that may already be provided by Cinnamon. Most findings
are advisory and do not automatically disqualify a pull request.
This check is not perfect and will not replace a normal review.
In case the original author does not wish to change the original design, it is worth noting that removing the call to setupUI at the end of calculatePrayerTimes solves the problem as well (although of course, not as elegantly as the one above).
It is not needed as before the calculatePrayerTimes call, a call to setupUI was already scheduled. This way, there's only one loop that goes back and forth between setupUI and refresh rather than multiple loops spawning at midnight.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #1547
Root cause
setupUIcalls refresh.refreshset a timer to callsetupUIevery 1 second.This resulted infinite loop.
At midnight this gets worst, because date changes, which will trigger
calculatePrayerTimesandcalculatePrayerTimesalso callssetupUI...Multiple infinite loops explains cpu spike at midnight.
Fix
Replaced refresh with a function
startUpdateTimerthat run once per second.Added updateCountdown checks if day changed and recalculate prayer times at midnight.
UI will only be built when needed instead of every second
Same features without infinite loops