Habitica: editing Dailies is slow or freezes / crashes website (calculating next due dates)

Created on 26 May 2017  Â·  10Comments  Â·  Source: HabitRPG/habitica

Three reports below from the Report a Bug guild of problems when editing Dailies because the calculation for "Next Due Dates" is slowing things down. I've noticed it myself now when testing Yearlies with large frequencies - initial loading of the edit form is slow and when I made a change to the repeat settings, the website hung while recalculating the next due dates.

Some initial thoughts about how to handle this (other ideas most welcome!):

  • only show the next due date and have a button for showing others after that (so only one calculation is done)
  • when editing the repeat settings, don't automatically change the next due dates; perhaps have a button that appears as soon as a change is detected and you click the button if you want to see the updated dates (useful if you're changing two or more settings at once - no need to wait for the recalculation after each step)
  • maybe do these fixes only when we can detect that the calculation is likely to be slow - e.g., for "daily" or "weekly" repeats with a small frequency number, just show all next due dates at once and refresh as soon as there's changes since there's unlikely to be any delay for them

yamo25000 (242241ad-cbf2-4f1d-8549-ed1f24a3476b) :
"Hello, I noticed a bug when making a yearly Daily. It seems that if one makes the value of X too high, the website will start to lag, and eventually crash. I think this is probably due to the algorithm that predicts the Daily's next active date, but that's just a guess."

Laura D (fbd1f053-a460-4b34-a893-2d5934b30e69) :
"... dear goodness, don't switch "every 365 days" to "yearly" before changing the 365. It froze for so long calculating the next run dates. Should have set that one to 1, then yearly, instead of the other way around. ;) LOL"

thebat137 (dea8a9e8-c084-438a-9a14-7fe96a73fd0a) :
"I'm really thrilled to see the new task frequency settings (daily/weekly/monthly/yearly), but ever since they were added, editing dailies seems to have gotten incredibly slow for me (in the browser). Opening a daily for editing takes a while, and then the response to clicking on different settings changes is somewhere between slow and non-existent... sometimes it slows things down badly enough that it locks up the whole browser."

important status in progress

Most helpful comment

Cool, I can get something pushed in the next couple of days. I actually found the culprit. It's the moment-recur plugin.

Important Note: These functions may be very inefficient/slow. They work by attempting to match every date from the start of a range until the desired number of dates have been generated. So if you attempt to get 10 dates for a rule that matches once a year, it will run the match function for ~3650 days.

I'm almost done with rewriting some code blocks then I'll add some tests.

All 10 comments

I'm marking this important because we've had three people notice this so far so it's likely to be common, and while this feature is new there'll be more editing of those settings than normal, so if we can think of a fast fix, that would be helpful for maybe many players.

Ah, yes. Next Due calcs are very slow. :P I like the button idea.

I'd like to take this on if you guys need something quick.

I should add to my report that, unlike the others, I have not yet created and was not trying to create any yearly or large-interval tasks. After the new feature was added, I created a couple new tasks with 1-month or 2-week repeat intervals, but that was it. And I think my problems started before creating those.

Also, I noticed that one of my tasks that existed before the changeover ended up in kind of an odd state after the changeover (possibly unrelatedly, but I mention it here just in case it helps). Before the changeover, it had been scheduled to happen on three specific days every week. After the changeover, it was scheduled to occur every 3 weeks, but still on the same set of days. It seems that in the translation from the old to new style repeats, something did not get converted correctly. I have a sort of hypothesis for what might have happened, based on the fact that at one point in the past I had had this task on an "every 3 days" schedule, and had only later switched it to an "every Tuesday, Thursday, and Sunday" schedule. I wonder if perhaps the "3" was invisibly retained as the "X" in "every X days", even though "every X days" was not actually active. So when the "every Tuesday, Thursday, Sunday" pattern that was actually active got converted into an "every X weeks on Tuesday, Thursday, and Sunday", the old hidden X=3 value was retained instead of a more appropriate X=1 value being written over it. Anyway, I dunno if this is a useful idea about how the repeat got screwed up, or if there's any possible connection between a screwed-up repeat and slow editing, but I just want to be complete.

@joe-salomon Yes, something quick would be good I think. I'm sorry we didn't reply yesterday. Please go ahead and comment here if you have questions.

@thebat137 Thank you for those details! I've noticed one or two other reports of odd scheduling so I've created https://github.com/HabitRPG/habitica/issues/8763 and copied your comment to it.

Cool, I can get something pushed in the next couple of days. I actually found the culprit. It's the moment-recur plugin.

Important Note: These functions may be very inefficient/slow. They work by attempting to match every date from the start of a range until the desired number of dates have been generated. So if you attempt to get 10 dates for a rule that matches once a year, it will run the match function for ~3650 days.

I'm almost done with rewriting some code blocks then I'll add some tests.

The daily and yearly calculations are the ones that take the longest. Do you just want me to fix the logic behind those? Or should I rewrite the weekly and monthly ones as well for consistency?

@joe-salomon Please rewrite all of them, thank you. I suspect it will help even in the daily and weekly cases, for example on slow computers, such as in this report made today in the Report a Bug guild, from Kella (b50b5e4d-0134-4e3b-9627-565840558f59):
"Related to the new repeat dailies problem, I realized the app wasn't working so switched to the website. I use chrome. Any time I try to edit a daily, it takes five minutes to open the edit screen, five minutes to allow me to switch from daily to weekly because it's defaulting to daily even if I have a only couple days selected, and then five minutes each to deselect or select a day of the week, with many "page not responding" errors in between. Firefox is marginally better, my boyfriend's computer is a little faster and fewer errors. I currently can't edit the days of the week of my dailies on my computer because it takes 30 minutes to edit one daily. I have a slowish computer but it's never done this before."

What is the proper behavior for this case:

Start date of 5/29/17 "Monthly" that repeats every 1 month, on the day of the week.

which results in
Repeats monthly every 1 months on the 5 Monday
Next Due Dates 07/31/2017, 10/30/2017, 01/29/2018, 04/30/2018, 07/30/2018, 10/29/2018

In the existing code,it skips the months in which there is no 5th Monday. Is this the correct behavior? Thanks!

Yes, that's currently considered the correct behaviour.

On Tue, 30 May 2017, 02:36 joe-salomon notifications@github.com wrote:

What is the proper behavior for this case:

Start date of 5/29/17 "Monthly" that repeats every 1 month, on the day of
the week.

which results in
Repeats monthly every 1 months on the 5 Monday
Next Due Dates 07/31/2017, 10/30/2017, 01/29/2018, 04/30/2018, 07/30/2018,
10/29/2018

In the existing code,it skips the months in which there is no 5th Monday.
Is this the correct behavior? Thanks!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/HabitRPG/habitica/issues/8756#issuecomment-304697970,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABbTAZIg4DnkJgGnSVAkUQjnKvJ7FZDCks5r-vQBgaJpZM4Nm81X
.

Was this page helpful?
0 / 5 - 0 ratings