DamascenoRafael / reminders-menubar

Simple macOS menu bar application to view and interact with reminders. Developed with SwiftUI and using Apple Reminders as a source.
GNU General Public License v3.0
2.45k stars 112 forks source link

Version 1.12.0 - App crashes #95

Closed LocheBC closed 1 year ago

LocheBC commented 1 year ago

I installed V1.12.0 using the zip file (not Homebrew). The app crashes and quit as soon as I click on the menu bar icon.

Tried to reboot, didn't change anything.

I then tried to do a complete uninstall of V1.11.0 using AppCleaner. Reinstalled V1.12.0, then when I click the icon, it crashes but does not quit (icon gets darker but nothing shows up, unresponsive).

Returned to V1.11.0 for the moment, although I'm very much looking forward for the URL implementation.

I'm on a MBP 14" M1 - Base model.

Cheers

DamascenoRafael commented 1 year ago

Thank you for reporting this @LocheBC. I'll try to check it later today.

Can you tell me what version of macOS you are using?

And just to confirm, v1.11.0 works fine, right?

LocheBC commented 1 year ago

Yes, no problem with V1.11.0!

I’m on macOS Ventura 13.2 (a) Beta - Build 22D7750270d

On Jan 4, 2023, at 1:31 PM, Rafael Damasceno @.***> wrote:

Thank you for reporting this @LocheBC https://github.com/LocheBC. I'll try to check it later today.

Can you tell me what version of macOS you are using?

And just to confirm, v1.11.0 works fine, right?

— Reply to this email directly, view it on GitHub https://github.com/DamascenoRafael/reminders-menubar/issues/95#issuecomment-1371448915, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4XQFVJZQK7KV6E7RYFJA4DWQXT4HANCNFSM6AAAAAATRHHTZE. You are receiving this because you were mentioned.

DamascenoRafael commented 1 year ago

hey @LocheBC. I talked to a friend running macOS 13.0.1 on an M1 and he had no issues. Same thing for me running macOS 13.1 on an Intel i7 MBP.

I'm wondering if it might be some problem happening only in macOS beta.

Do you think you could download the project and try to run it in Xcode? That way Xcode will possibly point out where it is crashing.

Another option would be to see the log which should be saved in ~/Library/Logs/DiagnosticReports/, the file name should start with "Reminders Menu Bar". To open 'Library', open Finder and hold down the Option key before clicking the 'Go' menu in Finder's menu bar.

LocheBC commented 1 year ago

Hi Rafael,

Here’s the log from the first time I ran V1.12.0

I don’t have XCode anymore, but I could redownload it if you can’t do anything with the log file.

Thanks for your work.

On Jan 4, 2023, at 7:38 PM, Rafael Damasceno @.***> wrote:

hey @LocheBC https://github.com/LocheBC. I talked to a friend running macOS 13.0.1 on an M1 and he had no issues. Same thing for me running macOS 13.1 on an Intel i7 MBP.

I'm wondering if it might be some problem happening only in macOS beta.

Do you think you could download the project and try to run it in Xcode? That way Xcode will possibly point out where it is crashing.

Another option would be to see the log which should be saved in ~/Library/Logs/DiagnosticReports/, the file name should start with "Reminders Menu Bar". To open 'Library', open Finder and hold down the Option key before clicking the 'Go' menu in Finder's menu bar.

— Reply to this email directly, view it on GitHub https://github.com/DamascenoRafael/reminders-menubar/issues/95#issuecomment-1371747264, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4XQFVOCK6ND4D53WKSBORTWQY62DANCNFSM6AAAAAATRHHTZE. You are receiving this because you were mentioned.

DamascenoRafael commented 1 year ago

I think the file was not attached, can you check? If you prefer you can send me the log by DM on twitter.

LocheBC commented 1 year ago

Reminders Menu Bar-2023-01-04-115523.ips.zip

Oh sorry, apparently GitHub doesn't support IPS files. Here's a zipped version.

peteschaffner commented 1 year ago

I'm running macOS 13.1 and experienced the same thing with the latest release (1.12.0).

I believe the problem occurs only if you haven't given access to Reminders. Then trying to instantiate an EKCalendar directly without specifying a type and store causes the crash.

Here's the exception:

2023-01-05 06:56:30.032725+0100 Reminders Menu Bar[69093:2014768] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Can't directly init a calendar. Use calendarWithEventStore'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000183aef3f8 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018363aea8 objc_exception_throw + 60
    2   EventKit                            0x000000019a91fa74 -[EKCalendar entityType] + 0
    3   Reminders Menu Bar                  0x00000001043dae08 $sSo10EKCalendarCABycfcTO + 24
    4   Reminders Menu Bar                  0x00000001043d6140 $sSo10EKCalendarCABycfC + 32
    5   Reminders Menu Bar                  0x00000001043d6104 $s18Reminders_Menu_Bar15UserPreferencesC18_calendarForSaving33_AF341C06C1B3CF2F212750EDC526AE54LL7Combine9PublishedVySo10EKCalendarCGvpfiAJyXEfU_ + 716
    6   Reminders Menu Bar                  0x00000001043d388c $s18Reminders_Menu_Bar15UserPreferencesCACyc33_AF341C06C1B3CF2F212750EDC526AE54Llfc + 716
    7   Reminders Menu Bar                  0x00000001043d3538 $s18Reminders_Menu_Bar15UserPreferencesCACyc33_AF341C06C1B3CF2F212750EDC526AE54LlfC + 44
    8   Reminders Menu Bar                  0x00000001043d34f8 $s18Reminders_Menu_Bar15UserPreferencesC8instance_WZ + 28
    9   libdispatch.dylib                   0x0000000104baa9d4 _dispatch_client_callout + 20
    10  libdispatch.dylib                   0x0000000104bac8f8 _dispatch_once_callout + 156
    11  Reminders Menu Bar                  0x00000001043d3590 $s18Reminders_Menu_Bar15UserPreferencesC8instanceACvau + 76
    12  Reminders Menu Bar                  0x00000001043f6d6c $s18Reminders_Menu_Bar11AppDelegateC04loadbC4IconyyF + 44
    13  Reminders Menu Bar                  0x00000001043f6e8c $s18Reminders_Menu_Bar11AppDelegateC09configurebC6Button33_1FFBA7C17FB91BC8FDAF4FA1F61CD6D5LLyyF + 64
    14  Reminders Menu Bar                  0x00000001043f6ab0 $s18Reminders_Menu_Bar11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVF + 216
    15  Reminders Menu Bar                  0x00000001043f6b54 $s18Reminders_Menu_Bar11AppDelegateC29applicationDidFinishLaunchingyy10Foundation12NotificationVFTo + 140
    16  SwiftUI                             0x00000001aad1f3c4 OUTLINED_FUNCTION_4 + 3176
    17  SwiftUI                             0x00000001aad1f598 OUTLINED_FUNCTION_4 + 3644
    18  CoreFoundation                      0x0000000183a69570 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
    19  CoreFoundation                      0x0000000183b07054 ___CFXRegistrationPost_block_invoke + 88
    20  CoreFoundation                      0x0000000183b06f9c _CFXRegistrationPost + 440
    21  CoreFoundation                      0x0000000183a3ab74 _CFXNotificationPost + 708
    22  Foundation                          0x000000018492872c -[NSNotificationCenter postNotificationName:object:userInfo:] + 88
    23  AppKit                              0x0000000186cfb810 -[NSApplication _postDidFinishNotification] + 284
    24  AppKit                              0x0000000186cfb5c0 -[NSApplication _sendFinishLaunchingNotification] + 172
    25  AppKit                              0x0000000186cf9654 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 488
    26  AppKit                              0x0000000186cf9260 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 492
    27  Foundation                          0x00000001849529d8 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 316
    28  Foundation                          0x0000000184952838 _NSAppleEventManagerGenericHandler + 80
    29  AE                                  0x0000000189dbe874 _AppleEventsCheckInAppWithBlock + 14804
    30  AE                                  0x0000000189dbe1a0 _AppleEventsCheckInAppWithBlock + 13056
    31  AE                                  0x0000000189db7240 aeProcessAppleEvent + 488
    32  HIToolbox                           0x000000018d15950c AEProcessAppleEvent + 68
    33  AppKit                              0x0000000186cf4730 _DPSNextEvent + 1412
    34  AppKit                              0x0000000186cf35b4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
    35  AppKit                              0x0000000186ce79e4 -[NSApplication run] + 464
    36  AppKit                              0x0000000186cbee28 NSApplicationMain + 880
    37  SwiftUI                             0x00000001aa6048a8 OUTLINED_FUNCTION_8 + 8244
    38  SwiftUI                             0x00000001ab7b97c0 OUTLINED_FUNCTION_11 + 188
    39  SwiftUI                             0x00000001aafdd83c OUTLINED_FUNCTION_1 + 136
    40  Reminders Menu Bar                  0x00000001043f604c $s18Reminders_Menu_Bar0abC0V5$mainyyFZ + 40
    41  Reminders Menu Bar                  0x00000001043f8688 main + 12
    42  dyld                                0x000000018366be50 start + 2544
)
DamascenoRafael commented 1 year ago

@peteschaffner thanks, I guess you're right. This could be the cause of the problem because in v1.12.0 I initialize the UserPreferences due to the custom icon before having the permission. I will release a fix for this!

DamascenoRafael commented 1 year ago

@LocheBC @peteschaffner I just released v1.12.1 📦 Can you please test and check if the problem is solved?

LocheBC commented 1 year ago

@DamascenoRafael No it didn't fix the issue for me.

I tried disabling the permission to access Reminders. Then, when I open V1.12.1, it prompts me to enable access. But then it crashes again.

I'll try to download XCode tonight.

DamascenoRafael commented 1 year ago

@LocheBC It makes sense that you're having a different issue because you already gave permission in a previous version of the app.

Please let me know if you run the app in Xcode as it will probably show an exception somewhere. I'm still not sure what could be happening.

peteschaffner commented 1 year ago

Both the distributed binary (turning off the existing Reminders permission in System Settings) and running in Xcode worked for me 👍

LocheBC commented 1 year ago

@DamascenoRafael

Apologies for the delay. I finally ran V1.12.1 with Xcode. Errors I get are all related to "Publishing changes from within view updates is not allowed, this will cause undefined behavior."

Not sure if there's a better way to share the error log, but here's a screenshot:

image

LocheBC commented 1 year ago

I just upgraded to MacOS Ventura 13.2 Beta 2 and I still have the same issue with V1.12.0/1.

V1.11.0 still works fine.

DamascenoRafael commented 1 year ago

hey @LocheBC, I'm still trying to understand what could be causing this issue. I installed macOS 13.2 Beta (22D5038i) but didn't have the same issue as you running v1.12.1.

About the screenshot you sent, did the purple warnings appear as soon as you clicked on the icon in the menu bar and then it crashed? In addition to these alerts, did no other appear? Xcode version you're using is 14.2 (14C18)?

LocheBC commented 1 year ago

@DamascenoRafael

Correct, the purple warnings appear as soon as I click on the menu bar icon and then it crashes.

No other alerts, just multiple of this same "Publishing changes from within view updates is not allowed, this will cause undefined behavior."

Yes, I'm using Xcode 14.2 (14C18).

EDIT: Also note that my screenshot shows both V1.11.0 running at the same time as V1.12.1 (through Xcode). I tested afterwards running just V1.12.1 and closed V1.11.0, but got the same crash report.

Let me know if I can help in any way.

DamascenoRafael commented 1 year ago

@LocheBC Still can't figure out why it's crashing for you, but it must have been some change between v1.11.0 and v1.12.0.

To try and narrow down what might be causing this can you please try the below changes in Xcode one at a time and see if that stops it from crashing?

  1. AppDelegate.swift L51:

    func loadMenuBarIcon() {
    -        let menuBarIcon = UserPreferences.instance.reminderMenuBarIcon
    -        statusBarItem.button?.image = menuBarIcon.image
    +        statusBarItem.button?.image = NSImage(systemSymbolName: "list.bullet", accessibilityDescription: nil)
    }
  2. EKReminder+Extensions.swift L62:

    // NOTE: This is a workaround to access the URL saved in a reminder.
    // This property is not accessible through the conventional API.
    var attachedUrl: URL? {
    +       return nil
        let backingObjectSelector = NSSelectorFromString("backingObject")
        let reminderSelector = NSSelectorFromString("_reminder")
        let attachmentsSelector = NSSelectorFromString("attachments")
    
        if let unmanagedBackingObject = self.perform(backingObjectSelector),
           let unmanagedReminder = unmanagedBackingObject.takeUnretainedValue().perform(reminderSelector),
           let unmanagedAttachments = unmanagedReminder.takeUnretainedValue().perform(attachmentsSelector),
           let attachments = unmanagedAttachments.takeUnretainedValue() as? [AnyObject] {
            for item in attachments {
                guard let unmanagedUrl = item.perform(NSSelectorFromString("url")),
                      let url = unmanagedUrl.takeUnretainedValue() as? URL else {
                          continue
                      }
                return url
            }
         }
        return nil
    }
DamascenoRafael commented 1 year ago

@LocheBC Let me know if you have the opportunity to try this out.

receyuki commented 1 year ago

@LocheBC Still can't figure out why it's crashing for you, but it must have been some change between v1.11.0 and v1.12.0.

To try and narrow down what might be causing this can you please try the below changes in Xcode one at a time and see if that stops it from crashing?

  1. AppDelegate.swift L51:
    func loadMenuBarIcon() {
-        let menuBarIcon = UserPreferences.instance.reminderMenuBarIcon
-        statusBarItem.button?.image = menuBarIcon.image
+        statusBarItem.button?.image = NSImage(systemSymbolName: "list.bullet", accessibilityDescription: nil)
    }
  1. EKReminder+Extensions.swift L62:
    // NOTE: This is a workaround to access the URL saved in a reminder.
    // This property is not accessible through the conventional API.
    var attachedUrl: URL? {
+       return nil
        let backingObjectSelector = NSSelectorFromString("backingObject")
        let reminderSelector = NSSelectorFromString("_reminder")
        let attachmentsSelector = NSSelectorFromString("attachments")

        if let unmanagedBackingObject = self.perform(backingObjectSelector),
           let unmanagedReminder = unmanagedBackingObject.takeUnretainedValue().perform(reminderSelector),
           let unmanagedAttachments = unmanagedReminder.takeUnretainedValue().perform(attachmentsSelector),
           let attachments = unmanagedAttachments.takeUnretainedValue() as? [AnyObject] {
            for item in attachments {
                guard let unmanagedUrl = item.perform(NSSelectorFromString("url")),
                      let url = unmanagedUrl.takeUnretainedValue() as? URL else {
                          continue
                      }
                return url
            }
         }
        return nil
    }

I got the same issue (similar exception in log) and the second method fixed it for me.

MacBook Pro (16-inch, 2019, intel) / MacBookPro16,1 Ventura 13.2 (22D49) Xcode 14.2 (14C18)

LocheBC commented 1 year ago

Hey @DamascenoRafael,

Sorry or the delay.

As @receyuki pointed out, the second change "fixed" it. But then obviously I couldn't access the URL tags.

So I investigated further and figured out the issue. I have reminders that have both an URL tag and an image associated to it. Thus, it has more than one attachment. Your workaround for the lack of URL API from Apple does not seem to handle multiple attachments. As soon as I deleted all the images in my Reminders, V1.12.1 would run just fine.

Now, I'm not good enough at coding to know how to handle the image attachments as well.

EDIT: To be clear, I personally don't need Reminders Menu Bar to display the images associated with a reminder. It just need to ignore these images and not crash.

Cheers!

Laurent

mittelgrau commented 1 year ago

As soon as i removed every Image in my Reminders, it started working again. Props for figuring it out & a big thank you for the great app!

DamascenoRafael commented 1 year ago

@receyuki and @mittelgrau sorry to hear that you are also facing this issue.

@LocheBC thank you for your investigation!! I was able to reproduce the issue and I'm already working on a fix.

DamascenoRafael commented 1 year ago

@LocheBC, @receyuki and @mittelgrau please try version 1.13.0 📦

LocheBC commented 1 year ago

Works for me! Thanks for your work @DamascenoRafael !