iOS 12 crash in event editor

Hi,


Some of my users are getting a crash in my app on iOS 12 when editing events. Below is the stack trace of the crash and as this is happening in the event editor I have no idea what is causing it.


Any ideas would be appreciated!


/Mark


Crashed: com.apple.main-thread
0  libdispatch.dylib              0x197995724 _dispatch_once_wait$VARIANT$mp + 212
1  EventKitUI                     0x1a9a918c4 _SharedDateFormatter + 156
2  EventKitUI                     0x1a9a91214 CalCalendar + 416
3  EventKitUI                     0x1a9a96ee4 -[TodayInvalidationTimerWrapper _setupTimeZoneTimer] + 172
4  EventKitUI                     0x1a9a96dd8 -[TodayInvalidationTimerWrapper init] + 68
5  EventKitUI                     0x1a9a973a0 ___RegisterForInvalidation_block_invoke + 232
6  libdispatch.dylib              0x1979f4484 _dispatch_client_callout + 16
7  libdispatch.dylib              0x197996710 _dispatch_once_callout + 28
8  EventKitUI                     0x1a9a90f80 _initDateFormatterWithCommaAndYear + 112
9  EventKitUI                     0x1a9a925cc CalStringForDateWithCommaAndYear + 24
10 EventKitUI                     0x1a9a4d70c _StringValuePartsForDateComponents + 592
11 EventKitUI                     0x1a9a50fe4 -[EKEventDateEditItem _resetStartString:endString:] + 300
12 EventKitUI                     0x1a9a503e4 -[EKEventDateEditItem _setStartDate:] + 144
13 EventKitUI                     0x1a9a4dce0 -[EKEventDateEditItem refreshFromCalendarItemAndStore] + 836
14 EventKitUI                     0x1a9ab816c -[EKCalendarItemEditItem setCalendarItem:store:] + 172
15 EventKitUI                     0x1a9b62be4 -[EKEventEditItem setCalendarItem:store:] + 144
16 EventKitUI                     0x1a9b6e840 -[EKCalendarItemEditor _setCalendarItemOnEditItems] + 212
17 EventKitUI                     0x1a9b6e908 -[EKCalendarItemEditor prepareEditItems] + 88
18 EventKitUI                     0x1a9b3b630 -[EKEventEditor prepareEditItems] + 48
19 EventKitUI                     0x1a9b6eb38 -[EKCalendarItemEditor setupForEvent] + 176
20 EventKitUI                     0x1a9b6dbfc -[EKCalendarItemEditor viewDidLoad] + 128
21 UIKitCore                      0x1c4f01e4c -[UIViewController loadViewIfRequired] + 1000
22 UIKitCore                      0x1c4f0227c -[UIViewController view] + 28
23 EventKitUI                     0x1a9b3b5b8 -[EKEventEditor preferredContentSize] + 28
24 UIKitCore                      0x1c4b77618 -[UIPresentationController preferredContentSizeDidChangeForChildContentContainer:] + 68
25 UIKitCore                      0x1c4b7363c __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 140
26 UIKitCore                      0x1c484b190 _runAfterCACommitDeferredBlocks + 296
27 UIKitCore                      0x1c48391d0 _cleanUpAfterCAFlushAndRunDeferredBlocks + 384
28 UIKitCore                      0x1c4868508 _afterCACommitHandler + 132
29 CoreFoundation                 0x197f49b94 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
30 CoreFoundation                 0x197f44828 __CFRunLoopDoObservers + 412
31 CoreFoundation                 0x197f44dc8 __CFRunLoopRun + 1264
32 CoreFoundation                 0x197f445b8 CFRunLoopRunSpecific + 436
33 GraphicsServices               0x19a1b8584 GSEventRunModal + 100
34 UIKitCore                      0x1c483f558 UIApplicationMain + 212
35 CalendarPlus                   0x100de3e38 main (main.m:13)
36 libdyld.dylib                  0x197a04b94 start + 4

Replies

I found a workaround for this crash, inspired by Konrad's approach above.


As I'm presenting the EKEventEditViewController in response to selection of an Activity from the Share screen, this was the cleanest way to defer setting the EKEvent property:


import UIKit
import EventKitUI

/**
 This subclass exists solely to provide a workaround for the crash desribed at https://forums.developer.apple.com/thread/109374.
 */
@objc class PEEventEditViewController: EKEventEditViewController {

    @objc var deferredEvent:EKEvent?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        if let de = self.deferredEvent {
            self.event = de
        }
    }

}

In the activityViewController method of my UIActivity subclass, I use it as follows:


- (UIViewController *) activityViewController {
    
    if (nil == _eventViewController) {
        _eventViewController = [[PEEventEditViewController alloc] init];
        _eventViewController.eventStore = [[PEEventStoreHelper sharedInstance] eventStore];
        _eventViewController.editViewDelegate = self;
    }
    
    for (id item in self.items) {
        if ([item isKindOfClass:[EKEvent class]]) {
            EKEvent *event = (EKEvent *) item;
            _eventViewController.deferredEvent = event;
        }
    }
    
    return _eventViewController;
}


_eventViewController is an ivar of type PEEventEditViewController *.

Having the exact same issue. On my side, it seems to be entirely random. I do set startDate and endDate of my event, but the crash doesn't always occur. I've tried to workaround of assigning the event after displaying the EKEventEditViewController, I'll see if it appears again.