thompsonate / Shifty

☀️ A macOS menu bar app that gives you more control over Night Shift.
http://shifty.natethompson.io
GNU General Public License v3.0
1.24k stars 33 forks source link

Shifty quits and doesn't reopen automatically when after Mac awakes from sleep #80

Closed derekschinke closed 5 years ago

derekschinke commented 5 years ago

When I open my MacBook Pro after it has been asleep, Shifty is not running, even though it was open when I closed it. I have to manually start the application again for it to change Dark Mode/Night Shift.

choco commented 5 years ago

I can't reproduce it on my setup. Have you set up macOS to logout when your computer goes to sleep or after a certain period of time? That's probably the only reason I can think of...

derekschinke commented 5 years ago

Not that I can tell. I only have it to make me type my password again after it wakes from sleep, not a complete logout. It actually just happened again; my screensaver started, I returned and typed in my password, and noticed that the icon was gone when it had been there just before. This doesn’t happen with other bar items.

On May 21, 2019, at 02:21, Enrico Ghirardi notifications@github.com wrote:

I can't reproduce it on my setup. Have you set up macOS to logout when your computer goes to sleep or after a certain period of time? That's probably the only reason I can think of...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/thompsonate/Shifty/issues/80?email_source=notifications&email_token=AD3F333FTA643VX65XSPDALPWO5LBA5CNFSM4HN5BQIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV3JURA#issuecomment-494312004, or mute the thread https://github.com/notifications/unsubscribe-auth/AD3F336XMYNTVF2HH6V2VQ3PWO5LBANCNFSM4HN5BQIA.

LumingYin commented 5 years ago

@derekschinke I can't reproduce it on my setup either, but I suspect this speculative change may fix your issue. Mind taking a look at ~/Library/Logs/DiagnosticReports, and see if there's any crash logs from Shifty? If so, could you kindly attach your crash report to this issue?

derekschinke commented 5 years ago

There's like a dozen in there, here's the latest one:

Shifty_2019-05-21-154534_Dereks-MacBook-Pro.txt

LumingYin commented 5 years ago

Thanks for providing the crash log, Derek! It indeed looks like the same issue I was investigating earlier. Preparing for a fix now.

saagarjha commented 5 years ago

It looks like -[NSArray count] is returning ULLONG_MAX for some reason.

LumingYin commented 5 years ago

It looks like -[NSArray count] is returning ULLONG_MAX for some reason.

I've pushed out Shifty 1.1.1 to work around this issue by not casting browser.windows into [Window], but -[NSArray count] returning ULLONG_MAX seems really strange.

Did you figure this out through the debugger or by looking at the crash log, and would you happen to have any idea as of why?

saagarjha commented 5 years ago

I looked at the crash log and disassembled (my) libSwiftFoundation.dylib. It's crashing with SIGILL in specialized arrayConditionalCast<A, B>(:) which means it probably hit a ud2 that Clang stuck into it. Looking at the function call graph the check is whether $r15 overflows if one is added to it, which from what I see contains the result of _CocoaArrayWrapper.endIndex at the time this check is performed.

saagarjha commented 5 years ago

Based on -[SBElementArray count], I think one of the AE* methods fails, returns an error, and this becomes a negative "count" when the framework fails to check this properly.

LumingYin commented 5 years ago

Based on -[SBElementArray count], I think one of the AE* methods fails, returns an error, and this becomes a negative "count" when the framework fails to check this properly.

Thanks for the insight! This definitely sounds plausible. I'll wait a bit for analytics from the tentative fix to come back, and see if this bug needs further attention.

choco commented 5 years ago

Nice, noticed this crash just today after upgrading to latest macOS version, didn't happen before (at least for me). This is probably worth a rdar imho.

saagarjha commented 5 years ago

Probably. I'd try to see if you can get this down to a reproducible test case: the Radar is unlikely to go anywhere without it, and it would probably help in debugging this issue if we have a reliable way to trigger it.

LumingYin commented 5 years ago

Analytics from the 1.1.1 update seem to indicate the workaround has indeed fixed the crashes in Shifty. If anyone ever figures out a reproducible test case per suggested by Saagar, filing a radar could still benefit other apps using the -[SBElementArray count] API.

saagarjha commented 4 years ago

Do you have any new crash logs?