ttscoff / bunch

Documentation repository for Bunch.app
https://bunchapp.co
115 stars 5 forks source link

Bunch firing at random (wrong) times #71

Open jgclark opened 3 years ago

jgclark commented 3 years ago

It feels like this can't be happening given the amount of testing Bunch has had. But I have only one Bunch and its firing at random times. Here's the start of the Bunch file:

title: πŸ“† Daily Review
open at: 21:15
close at: 22:45
---

# Hide almost everything at 9.15pm

And here's an excerpt from the log from before and during the odd firing:

2021-05-25 11:29:12: βšͺ[Review] Opening app BusyContacts
2021-05-25 11:29:12: βšͺ[Review] Opening app Contacts
2021-05-26 00:22:52: βšͺ[Review] Opening from daily timer 25/05/2021, 21:15
2021-05-26 00:23:07: βšͺ[Review] Open >>>>>>>>>>>>>>>>>>>>>
2021-05-26 00:23:07: 🟑[Review] Scheduled to open daily starting 26/05/2021, 21:15
2021-05-26 00:23:07: 🟑[Review] Scheduled to close 26/05/2021, 22:45
2021-05-26 00:23:07: βšͺ[Review] Launching app (Finder) and hiding
2021-05-26 00:23:07: βšͺ[Review] Launching app (iTerm)

So it fired at 00:23 ...

I'm running Bunch 1.4.0 (102) on macOS 11.2.3.

ttscoff commented 3 years ago

I'm wondering if something screwy is going on with date formats. My log shows the "Scheduled to..." messages with 12-hour time, yours shows 24 hour time. Could be a localization thing, I suppose.

Does the Bunch also fire at the correct time, or is it just randomly off? And does it fire multiple random times per day?

I know this is a bit tricky to debug, but I have a couple of scheduled Bunches that always (and only) go off when they should, so I know that at least "on my machine" the feature is working correctly.

jgclark commented 3 years ago

I'm wondering if something screwy is going on with date formats. My log shows the "Scheduled to..." messages with 12-hour time, yours shows 24 hour time. Could be a localization thing, I suppose.

Ah, could well be. I'm writing plugins for NotePlan 3, and I've suffered with dealing with 12 / 24-hour time with different users.

Does the Bunch also fire at the correct time, or is it just randomly off? And does it fire multiple random times per day?

No: it never seems to fire at the right time. I don't think I've seen it fire more than once a day, but not always at the same time.

I know this is a bit tricky to debug, but I have a couple of scheduled Bunches that always (and only) go off when they should, so I know that at least "on my machine" the feature is working correctly.

Naturally. I hesitated to report this because it feels so weird that it might be a new bug. It has been present over several different beta versions.

ttscoff commented 3 years ago

Just to satisfy my curiosity, could you try changing the open on and close on to 12 hour time with meridian (e.g. 6:15pm)? I'm just wondering if something is going sideways in the string-to-time conversion.

You can try setting the time for 1 minute in the future and seeing if it fires as expected. Let me know.

-Brett

On 28 May 2021, at 16:27, Jonathan Clark wrote:

I'm wondering if something screwy is going on with date formats. My log shows the "Scheduled to..." messages with 12-hour time, yours shows 24 hour time. Could be a localization thing, I suppose.

Ah, could well be. I'm writing plugins for NotePlan 3, and I've suffered with dealing with 12 / 24-hour time with different users.

Does the Bunch also fire at the correct time, or is it just randomly off? And does it fire multiple random times per day?

No: it never seems to fire at the right time. I don't think I've seen it fire more than once a day, but not always at the same time.

I know this is a bit tricky to debug, but I have a couple of scheduled Bunches that always (and only) go off when they should, so I know that at least "on my machine" the feature is working correctly.

Naturally. I hesitated to report this because it feels so weird that it might be a new bug. It has been present over several different beta versions.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/bunch/issues/71#issuecomment-850680651

jgclark commented 3 years ago

Yep, that appears to work now.

(And through doing so, I discover that the Stream Deck mac app doesn't respect your @@ command. It appears non-standard, not having a dock icon, or an entry in the usual ⌘Tab switcher list.)

Thanks.

On Fri, 28 May 2021 at 22:30, Brett Terpstra @.***> wrote:

Just to satisfy my curiosity, could you try changing the open on and close on to 12 hour time with meridian (e.g. 6:15pm)? I'm just wondering if something is going sideways in the string-to-time conversion.

You can try setting the time for 1 minute in the future and seeing if it fires as expected. Let me know.

-Brett

On 28 May 2021, at 16:27, Jonathan Clark wrote:

I'm wondering if something screwy is going on with date formats. My log shows the "Scheduled to..." messages with 12-hour time, yours shows 24 hour time. Could be a localization thing, I suppose.

Ah, could well be. I'm writing plugins for NotePlan 3, and I've suffered with dealing with 12 / 24-hour time with different users.

Does the Bunch also fire at the correct time, or is it just randomly off? And does it fire multiple random times per day?

No: it never seems to fire at the right time. I don't think I've seen it fire more than once a day, but not always at the same time.

I know this is a bit tricky to debug, but I have a couple of scheduled Bunches that always (and only) go off when they should, so I know that at least "on my machine" the feature is working correctly.

Naturally. I hesitated to report this because it feels so weird that it might be a new bug. It has been present over several different beta versions.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/bunch/issues/71#issuecomment-850680651

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttscoff/bunch/issues/71#issuecomment-850685811, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESRSECOSHKA2SOY6JNTTQADOPANCNFSM45TC36PA .

-- -- Jonathan

ttscoff commented 3 years ago

I'll look into why 24 hour time might be misinterpreted. It really should work.

Much like Bunch itself, the Stream Deck app runs as a background app, only existing in the menu bar. Background apps don't respond to any hide/activate commands, unfortunately. Sometimes you can add AppleScript to hide them, but I doubt Stream Deck has a library for that.

-Brett

On 28 May 2021, at 16:45, Jonathan Clark wrote:

Yep, that appears to work now.

(And through doing so, I discover that the Stream Deck mac app doesn't respect your @@ command. It appears non-standard, not having a dock icon, or an entry in the usual ⌘Tab switcher list.)

Thanks.

On Fri, 28 May 2021 at 22:30, Brett Terpstra @.***> wrote:

Just to satisfy my curiosity, could you try changing the open on and close on to 12 hour time with meridian (e.g. 6:15pm)? I'm just wondering if something is going sideways in the string-to-time conversion.

You can try setting the time for 1 minute in the future and seeing if it fires as expected. Let me know.

-Brett

On 28 May 2021, at 16:27, Jonathan Clark wrote:

I'm wondering if something screwy is going on with date formats. My log shows the "Scheduled to..." messages with 12-hour time, yours shows 24 hour time. Could be a localization thing, I suppose.

Ah, could well be. I'm writing plugins for NotePlan 3, and I've suffered with dealing with 12 / 24-hour time with different users.

Does the Bunch also fire at the correct time, or is it just randomly off? And does it fire multiple random times per day?

No: it never seems to fire at the right time. I don't think I've seen it fire more than once a day, but not always at the same time.

I know this is a bit tricky to debug, but I have a couple of scheduled Bunches that always (and only) go off when they should, so I know that at least "on my machine" the feature is working correctly.

Naturally. I hesitated to report this because it feels so weird that it might be a new bug. It has been present over several different beta versions.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/bunch/issues/71#issuecomment-850680651

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttscoff/bunch/issues/71#issuecomment-850685811 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESRSECOSHKA2SOY6JNTTQADOPANCNFSM45TC36PA .

-- -- Jonathan

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/ttscoff/bunch/issues/71#issuecomment-850691382

ttscoff commented 3 years ago

Ok, I can't find any reason that 24 hour time wouldn't work, and it appears to work fine for me. Basically if there's no meridian and the first part of the string before the colon is between 0 and 24, it should interpret it correctly. In fact, if there is a meridian (anything starting with a or p) after the time, it converts it to 24 hour time by adding 12 if the meridian starts with p and the hour is less than 12. So if 12-hour time works, 24 really should.

When an open or close time is specified and the Bunch is in the opposite state (e.g. the Bunch has a scheduled open and is currently closed), the item in the menu gets an alarm clock and a tooltip showing the next event. When you hover over the menu item for a few seconds, it should show you the time and date for the next scheduled event. Could you test with both 12 hour and 24 hour format for the same time and see if the result in the menu is correct and the same for both?

Also, upon review, I set up the log to show whatever localized format the system is set to, so the fact that yours was showing DD/MM/YYYY HH:MM isn't surprising. Just so I can be on the same page for testing, what are the locale and format settings in System Preferences -> Date & Time -> Date & Time -> Open Language & Region...? A screenshot of that pane would be fine. I'm not sure it has anything to do with the issue, but just in case.

jgclark commented 3 years ago

Thanks. Language & Region settings: Region: United Kingdom First d o w: Monday Calendar: Gregorian Time format: 24 hour

β†’ Tuesday, 1 June 2021 at 22:55:42 BST 01/06/2021, 22:55

On Sat, 29 May 2021 at 11:49, Brett Terpstra @.***> wrote:

Ok, I can't find any reason that 24 hour time wouldn't work, and it appears to work fine for me. Basically if there's no meridian and the first part of the string before the colon is between 0 and 24, it should interpret it correctly. In fact, if there is a meridian (anything starting with a or p) after the time, it converts it to 24 hour time by adding 12 if the meridian starts with p and the hour is less than 12. So if 12-hour time works, 24 really should.

When an open or close time is specified and the Bunch is in the opposite state (e.g. the Bunch has a scheduled open and is currently closed), the item in the menu gets an alarm clock and a tooltip showing the next event. When you hover over the menu item for a few seconds, it should show you the time and date for the next scheduled event. Could you test with both 12 hour and 24 hour format for the same time and see if the result in the menu is correct and the same for both?

Also, upon review, I set up the log to show whatever localized format the system is set to, so the fact that yours was showing DD/MM/YYYY HH:MM isn't surprising. Just so I can be on the same page for testing, what are the locale and format settings in System Preferences -> Date & Time -> Date & Time -> Open Language & Region...? A screenshot of that pane would be fine. I'm not sure it has anything to do with the issue, but just in case.

β€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttscoff/bunch/issues/71#issuecomment-850812767, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESSABOCBFX45W27UT7DTQDBCBANCNFSM45TC36PA .

-- -- Jonathan

jgclark commented 3 years ago

It's still firing at odd times. For example the bunch file that starts:

---
title: πŸ“† Daily Review
open at: 10:15pm
close at: 11:15pm
---

has just fired now. See the timing from the log:

2021-09-04 11:38:16: βšͺ[Review] Opening from daily timer 01/09/2021, 22:15 2021-09-04 11:38:31: βšͺ[Review] Open >>>>>>>>>>>>>>>>>>>>> 2021-09-04 11:38:31: 🟑[Review] Scheduled to open daily starting 04/09/2021, 22:15 2021-09-04 11:38:31: 🟑[Review] Scheduled to close 04/09/2021, 23:15 2021-09-04 11:38:31: βšͺ[Review] Hiding all apps 2021-09-04 11:38:31: βšͺ[Review] Launching app (NotePlan 3 Beta) ...

I'd been using the mac for some hours, so this wasn't related to firing on log in or wake from sleep. Running bunch 1.4.5 (119) on macOS 11.5.2.

esamecar commented 2 years ago

I have a similar problem but the other way round. It is scheduled to run Fridays at 12:55pm and it gets scheduled for Saturdays at a random time.

CleanShot 2021-10-30 at 16 48 33 CleanShot 2021-10-30 at 16 48 13

I am running Bunch under German time and region settings (24h format, macOS Version 11.6.1 (20G224)) BUT changing the bunch entries to 24 h format (omitting the pm) seems to correct my problem.

Kind regards

Marco

ttscoff commented 2 years ago

Yeah, this one is still baffling me. It has to have something to do with the region settings, but I'm having trouble finding anything that looks problematic in the C library I'm using for the natural date conversion.

@esamecar is the "random time" different every time, either after "Refresh Bunches" or after a quit and restart of Bunch? Like is it making the same bad interpretation every time, or is it truly random?

esamecar commented 2 years ago

@ttscoff Okay, it does seem to be different or more complicated. Since it worked this morning after switching from am/pm to 24h, I assumed that would be the problem. I just changed it back to 12:55pm for test purposes and it is still interpreted correctly. If I had to guess now, I would say that it is summer time/winter time related bug? Until yesterday it didn't work reproducibly and since today (change to winter time), it seems to work, no matter how I enter it...!

ttscoff commented 2 years ago

Interesting. It really should just be interpreting the time to a date object and applying it to the system time, so I'm not sure why a time change would affect it (as long as the system time has updated). I'll see if I can find anything weird in that direction, though.

Since 12:55pm is the same as 12:55 in 24h, could you test with 1pm and 13:00 to see if those have the same results now?

esamecar commented 2 years ago

@ttscoff yes, both variants show the correct date with 13:00

CleanShot 2021-11-02 at 07 16 16
esamecar commented 2 years ago

BUT for another bunch it is still not correct:

CleanShot 2021-11-02 at 10 57 44 CleanShot 2021-11-02 at 10 57 20

It should open several times on weekdays but is scheduled for in 6 days? After changing to 24 h format it seems to have corrected itself.

BUT after running once it gets confused again 😒

CleanShot 2021-11-02 at 13 11 30

To make a long story short: scheduling is broken for me.

lsps9150414 commented 2 years ago

I'm having the same issue, hovering shows the expected schedule but it just fires at a random time.

ttscoff commented 2 years ago

I'm having the same issue, hovering shows the expected schedule but it just fires at a random time.

@lsps9150414 could you browse through the history of this thread and let me know if there are any similarities in your setup? Like region settings, 24h vs 12h time formats, etc. Finding a common thread would really help narrow down the issue.

lsps9150414 commented 2 years ago

@ttscoff Screen Shot 2022-02-16 at 7 54 56 PM Screen Shot 2022-02-16 at 7 55 34 PM

and the config I use:

// For multiple times
open on: Mon Tue Wed Thur Fri Sat 08:00am, Mon Tue Wed Thur Fri Sat 06:45pm

// For a single time
open on: Mon, Tue, Wed, Thur, Fri, Sat 10:30pm
ttscoff commented 2 years ago

@lsps9150414 And is any particular Bunch firing randomly, or all scheduled Bunches? If you switch the time specification to 24h time (e.g. 06:45pm => 18:45), does it change anything? That seems to be a common factor, but apparently it can go both ways and neither is a permanent fix.

I haven't dug into this issue for a while but hopefully this weekend I'll get some time to try to narrow down the causes.

There are actually 2 different bug reports in this thread: in some cases the time is clearly interpreted incorrectly and the hover shows an inaccurate time, in the other cases the hover shows the correct time but the Bunch actually triggers at an unpredictable time.

Scheduling has always worked perfectly for me on my machine, but I'm clearly not compensating for variables. Thus far all of the reports seem to be from non-US systems (but all Gregorian calendars), so I need to figure out what would affect region changes would have on the methods I've used.

lsps9150414 commented 2 years ago

@ttscoff Thank you, I will try using 24h format in my bunch formatter.

It seems to have happened to 3 of my scheduled Bunches so far.

May I ask which system calendar you are using?

lsps9150414 commented 2 years ago

Hi @ttscoff I have been testing with 24h format for a while but unfortunately, the same issue still occurs.

ttscoff commented 2 years ago

Thanks for the update. I'm beginning to wonder if it's an Apple bug, but I haven't narrowed it down enough to try reporting it yet.

On 8 Mar 2022, at 7:09, Philip Chen wrote:

Hi @ttscoff I have been testing with 24h format for a while but unfortunately, the same issue still occurs.

-- Reply to this email directly or view it on GitHub: https://github.com/ttscoff/bunch/issues/71#issuecomment-1061759020 You are receiving this because you were mentioned.

Message ID: @.***>

lsps9150414 commented 2 years ago

@ttscoff hey just following up are there any new findings?

ttscoff commented 2 years ago

Sorry, haven't found any new leads on this yet. I may have to rethink the whole setup for creating timers, but not sure what other approach I could take. Will consult with some other automation devs when I have time.

lnrdgrnt commented 3 months ago

I am also having the same problem. For a long time (months) my scheduled bunch would open and close perfectly on time. Then something changed. Unfortunately, I don't know what - as that would be helpful for narrowing down the problem.

But as you can see from the log, bunch doesn't know what time it is!

2024-06-26 08:38:08: 🟑[everyday] Scheduled to open daily starting 27/06/2024, 08:00
2024-06-26 08:38:08: 🟑[everyday] Scheduled to close 26/06/2024, 19:00
2024-06-27 06:22:54: βšͺ[everyday] Closing from daily timer 26/06/2024, 19:00

Much like @jgclark - if I change the scheduled time for one or two minutes in the future, it works perfectly. Then, over the course of a few hours, something happens and the bunch doesn't run.

I am in England so currently British Summer Time. But for all the months that the bunch was running correctly I was also in this timezone.

Any thoughts appreciated! I was wondering if there was a way to trigger a bunch automatically by some other method as a workaround.

Thank you!

ttscoff commented 3 months ago

Yeah, I still haven't been able to track this down, something about interval timers in macOS. Another option is to use launchd with a script that calls the URL handler for Bunch. I've created a bunch CLI that simplifies that process, and there's a great app called LaunchControl that simplifies creating tasks for launchd.