sfsam / Itsycal

Itsycal is a tiny calendar for your Mac's menu bar. http://www.mowglii.com/itsycal
MIT License
3.25k stars 234 forks source link

Setting ShowLocation with `defaults` renders app unusable #231

Closed clanktron closed 9 months ago

clanktron commented 9 months ago

Itsycal randomly stopped showing any UI. It doesn't seem to be frozen or anything and there aren't any crashes. That being said I can't get the calendar popup to show or the preferences pane to come up. I've tried launching it from finder and the native apple launcher. I've tried rebooting and reinstalling ityscal (homebrew) with no luck.

https://github.com/sfsam/Itsycal/assets/52805671/330af6b5-ac14-4a21-a077-185980d6dc63

The most recent console messages when filtering for 'itsycal' are shown below.

default runningboardd   Assertion did invalidate due to timeout: 218-353-1673 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043])    23:29:26.395598-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:29:26.497864-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractiveFocal)    23:29:26.497874-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:29:26.497920-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:29:26.497973-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.133450-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.456329-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.459095-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.542952-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.545948-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.646218-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.652048-0700
default Itsycal [com.apple.calendar.agentLink.log.cache] [Client side cache is {
    CalSessionStata =     {
        CaliMIPSessionID = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p23" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/CalDAVPrincipal/p8" = 4;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/ExchangePrincipal/p32" = 1;
        "x-coredata://16438452-D079-4500-86BC-6FBE200337EF/SubscriptionInfo/p2" = 1;
    };
}]  23:29:44.736283-0700
default runningboardd   Invalidating assertion 218-142-1671 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) from originator [daemon<com.apple.coreservices.launchservicesd>:142] 23:29:45.450476-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:29:45.466555-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:29:45.467170-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:29:45.467242-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Set darwin role to: UserInteractive   23:29:45.467369-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:29:45.467468-0700
default runningboardd   Acquiring assertion targeting [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] from originator [daemon<com.apple.WindowServer(88)>:171] with description <RBSAssertionDescriptor| "AppDrawing" ID:218-171-1739 target:1043 attributes:[
    <RBSDomainAttribute| domain:"com.apple.appnap" name:"AppDrawing" sourceEnvironment:"(null)">,
    <RBSAcquisitionCompletionAttribute| policy:AfterApplication>
    ]>  23:31:43.753844-0700
default runningboardd   Assertion 218-171-1739 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) will be created as active 23:31:43.754012-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:31:43.754908-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:31:43.754906-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:31:43.754941-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:31:43.754970-0700
default runningboardd   Acquiring assertion targeting [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] from originator [daemon<com.apple.WindowServer(88)>:171] with description <RBSAssertionDescriptor| "AppVisible" ID:218-171-1753 target:1043 attributes:[
    <RBSDomainAttribute| domain:"com.apple.appnap" name:"AppVisible" sourceEnvironment:"(null)">,
    <RBSAcquisitionCompletionAttribute| policy:AfterApplication>
    ]>  23:31:43.775892-0700
default runningboardd   Assertion 218-171-1753 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) will be created as active 23:31:43.776025-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:31:43.776659-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:31:43.776690-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:31:43.776786-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:31:43.776860-0700
default runningboardd   Acquiring assertion targeting [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] from originator [daemon<com.apple.WindowServer(88)>:171] with description <RBSAssertionDescriptor| "FUSBProcessWindowState: visible" ID:218-171-1754 target:1043 attributes:[
    <RBSDomainAttribute| domain:"com.apple.fuseboard" name:"Visible" sourceEnvironment:"(null)">,
    <RBSAcquisitionCompletionAttribute| policy:AfterApplication>
    ]>  23:31:43.784432-0700
default runningboardd   Assertion 218-171-1754 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) will be created as active 23:31:43.784543-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:31:43.784997-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:31:43.784995-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:31:43.785024-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:31:43.785057-0700
default runningboardd   Invalidating assertion 218-171-1753 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) from originator [daemon<com.apple.WindowServer(88)>:171] 23:31:55.940191-0700
default runningboardd   Invalidating assertion 218-171-1754 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) from originator [daemon<com.apple.WindowServer(88)>:171] 23:31:55.974199-0700
default runningboardd   Removed last relative-start-date-defining assertion for process app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>  23:31:56.042711-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:31:56.083126-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:31:56.084911-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:31:56.085280-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:31:56.088234-0700
default runningboardd   Invalidating assertion 218-171-1739 (target:[app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043]) from originator [daemon<com.apple.WindowServer(88)>:171] 23:32:20.766531-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring jetsam update because this process is not memory-managed 23:32:20.878727-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring suspend because this process is not lifecycle managed    23:32:20.879009-0700
default runningboardd   [app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>:1043] Ignoring GPU update because this process is not GPU managed   23:32:20.880137-0700
default runningboardd   Calculated state for app<application.com.mowglii.ItsycalApp.55996869.55996875(501)>: running-active (role: UserInteractive) 23:32:20.881591-0700
sfsam commented 9 months ago

Thanks for reporting. What happens if you delete it and then download it from the website instead of Homebrew?

clanktron commented 9 months ago

That didn't do anything for me but the following script I threw together fixed the issue.

#!/bin/sh
pkill Itsycal && 
    defaults delete com.mowglii.ItsycalApp && 
    open -a Itsycal

It looks like it only happens when the defaults utility is used to write to the ShowLocation key. All the other keys are fine to modify it seems.

Running the test script below works perfectly fine to set my defaults. However if I uncomment the line setting ShowLocation it'll render the app in the aforementioned unusable state. This happens whether its set to 0 or 1, regardless of whether the defaults write command is even changing the value set by the gui.

#!/bin/sh

if pgrep Itsycal > /dev/null; then
    pkill Itsycal
fi
if defaults domains | grep com.mowglii.ItsycalApp > /dev/null; then
    defaults delete com.mowglii.ItsycalApp
fi

defaults write com.mowglii.ItsycalApp ClockFormat "E MMM d" &&
defaults write com.mowglii.ItsycalApp HideIcon 1 &&
defaults write com.mowglii.ItsycalApp SUEnableAutomaticChecks 0 &&
defaults write com.mowglii.ItsycalApp ShowEventDays 7 &&
defaults write com.mowglii.ItsycalApp SizePreference 2 &&
defaults write com.mowglii.ItsycalApp "NSStatusItem Preferred Position ItsycalStatusItem" 110 &&
# defaults write com.mowglii.ItsycalApp ShowLocation 1 &&
open -a Itsycal

I took it from previously closed issues that defaults was the way to "export/backup" my config. Is this not supported?

sfsam commented 9 months ago

I tried your script with the ShowLocation line both commented and uncommented (and also with both 0 and 1), but I could not reproduce the behavior you're experiencing. I am wondering what other differences there may be between our systems. I ran it on Ventura as well as Sonoma.

clanktron commented 9 months ago

Both systems I've tried it on are running monterey 12.7

uname -a
# Darwin clayton-mbp 21.6.0 Darwin Kernel Version 21.6.0: Fri Sep 15 16:17:23 PDT 2023; root:xnu-8020.240.18.703.5~1/RELEASE_X86_64 x86_64 i386 Darwin
sfsam commented 9 months ago

Can you trying changing that line to this:

defaults write com.mowglii.ItsycalApp ShowLocation -bool YES &&

I was able to reproduce the behavior on Monterey and making the above change worked for me. I will have to investigate the reason why.

clanktron commented 9 months ago

Cool that works for me too. Looks like it works anytime you enter it as a boolean through defaults:

defaults write com.mowglii.ItsycalApp ShowLocation -bool true
defaults write com.mowglii.ItsycalApp ShowLocation -bool false
defaults write com.mowglii.ItsycalApp ShowLocation -bool YES
defaults write com.mowglii.ItsycalApp ShowLocation -bool NO

I still have the problem though of importing my config 😅

I generally save any relevant bits from defaults read to a file and then apply them with default import for all my preferred apps. Running read gives me the following:

defaults read com.mowglii.ItsycalApp
# {
#     ClockFormat = "E MMM d";
#     HideIcon = 1;
#     "NSStatusItem Preferred Position ItsycalStatusItem" = 90;
#     "NSWindow Frame SUUpdateAlert" = "968 14 938 518 0 0 1920 1080 ";
#     SUEnableAutomaticChecks = 0;
#     SUHasLaunchedBefore = 1;
#     SULastCheckTime = "2023-10-11 01:47:04 +0000";
#     SUSkippedVersion = 2260;
#     SelectedCalendars =     (
#         "F3E57387-3448-427D-ADD9-7C682C52778D",
#         "E595BDF8-E722-4A11-AE67-6D01C8B4E353",
#         "69FAB19A-D295-4804-BCF9-7D39F318C9EE",
#         "A7DD60A0-BAA2-4F96-A41A-520E1C9A6693",
#         "EF6A98AC-0449-4501-B7DC-4DB436EBA0AC",
#         "71FCE555-7B32-4963-BD1A-40BA9557692D",
#         "238CCD93-0198-47A4-BDA6-9896DA1A0C28",
#         "ED57D1DC-54EC-4A4F-82FC-BA1274CE6AB0",
#         "C649B892-45A1-4EB4-993E-400A8A5F83DF",
#         "15FB96F8-BC99-4FC8-90BF-7FD8DD5459AB"
#     );
#     ShowEventDays = 7;
#     ShowLocation = 0;
#     SizePreference = 2;
# }

of which I save the following to a file:

cat Itsycal.plist
# {
#     ClockFormat = "E MMM d";
#     HideIcon = 1;
#     SUEnableAutomaticChecks = 0;
#     "NSStatusItem Preferred Position ItsycalStatusItem" = 90;
#     ShowEventDays = 7;
#     SizePreference = 2;
# }

Running defaults import com.mowglii.ItsycalApp Itsycal.plist imports these just fine. That being said the equivalent of writing a bool in this file would be a 0 or 1, and importing the config when it contains either of those for ShowLocation reproduces the bug. I've tried changing it to YES/NO/true/false and it seems that regardless of the value that's written the bug is reproduced.

sfsam commented 9 months ago

I don't know why Monterey is different from Ventura and Sonoma (which both work fine). There is a defaults read-type <domain> <key> command which gives the type (e.g. BOOL) of each <key> in <domain>. I guess you could do defaults read... to get everything and then iterate over the keys, calling defaults read-type on each and using the output to generate a fully qualified defaults write... command for each key.