17 Replies
      Latest reply on Feb 20, 2019 6:42 AM by bloemy7
      MarkOfSweden Level 1 Level 1 (0 points)



        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!




        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
        • Re: iOS 12 crash in event editor
          kysk Level 1 Level 1 (0 points)

          Same here.


          But I can not found how to reproduce it yet...

          • Re: iOS 12 crash in event editor
            schmidiii Level 1 Level 1 (0 points)

            i see that exact stack trace when i create a ```EKEventEditViewController``` and give it a EKEvent.


            some little info i found so far:

            - The crash only happens when i set a start and end date on the `EKEvent` and `isAllDay` to true.

            - if `isAllDay` is set to false or if the dates are ommited the app does not crash


            But something else must be happening as well since i am not able to reproduce this behaviour with a small demonstration app.

            consider me very confused...



            thanks to kysk i can confirm that setting a timezone different than your device/system timezone will lead to the crashing behaviour.

            • Re: iOS 12 crash in event editor
              kysk Level 1 Level 1 (0 points)



              I've create a reproduction code here.

              (And of cource you can run this project on your machine)


              I will post to a bug-reporter for this problem later.

                • Re: iOS 12 crash in event editor
                  schmidiii Level 1 Level 1 (0 points)

                  what is the status of this, could you already report the issue? i would love to follow the issue



                    • Re: iOS 12 crash in event editor
                      kysk Level 1 Level 1 (0 points)

                      (I post on bugreport.apple.com...)



                      I've found another case.



                      1. Turn on 'Time Zone Override' on Calendar settings.

                      2. Set the time zone to as you like ( Asia/Japan for example).


                      [Reproduce example]

                      1. Create EKEvent object, allDay = true.

                      2. Open EKEventEditViewController with this event.

                      3. Crash


                      [How to resolve]

                      Turn off 'Time Zone Override'

                  • Re: iOS 12 crash in event editor
                    nicolai Level 1 Level 1 (0 points)

                    I see the same. Never in simulator but consistently on device. I do not set allDay which means it defaults to 0 (NO).


                    The crash only appear when start date is set.


                    I see the same when editing events, i.e. when I give EKEventEditViewController an EKEvent retrieved from the event store.

                    • Re: iOS 12 crash in event editor
                      konrad.zdunczyk.luxmed Level 1 Level 1 (0 points)

                      I found workaround for this issue. If you set event AFTER present a view controller then crash doesn't occure.

                      let viewController = EKEventEditViewController()
                      viewController.editViewDelegate = self
                      viewController.eventStore = store
                      self.present(viewController, animated: true)
                      DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
                          viewController.event = event




                      I noticed that when note is added to EKEvent object then note is not present (and eventualy save) in EKEventEditViewController.


                      let event: EKEvent = ... // Complete event with dates and note
                      let vc = EKEventEditViewController()
                      vc.editViewDelegate = self
                      vc.eventStore = store
                      if #available(iOS 12, *) {
                       // Event without dates doesn't crash, but add note to vc
                       let fakeEvent: EKEvent = ... // Object with the same info as event but without startDate and endDate
                       fakeEvent.startDate = nil
                       fakeEvent.endDate = nil
                       vc.event = fakeEvent
                       self.present(vc, animated: animated) {
                        // When event is change after present then vc is in edit mode
                       DispatchQueue.main.async {
                        // Event with date after present vc doeasn't crash, but add date to vc
                          vc.event = event
                      } else {
                        vc.event = event
                        parentViewController.present(vc, animated: animated)
                      • Re: iOS 12 crash in event editor
                        lsykora Level 1 Level 1 (0 points)

                        My testing team said they encountered this issue (same stack trace) and I have not been able to reproduce it.


                        Can someone give the minimum necessary conditions to observe this crash?


                        I'm on iOS 12, I have ensured my event has allDay set to YES. The startDate is set, then allDay, then an endDate is calculated as 1 day from the startDate and set.


                        I have tried testing with a time zone override but that does not appear to matter.

                        • Re: iOS 12 crash in event editor
                          StephenT Level 1 Level 1 (0 points)

                          This appears to be fixed for me in iOS 12.1. My app was previously crashing exactly as described by OP. No more, post updating the OS to 12.1.

                            • Re: iOS 12 crash in event editor
                              StephenT Level 1 Level 1 (0 points)

                              It seems I spoke too soon. Still crashing for me in 12.1.1.

                              • Re: iOS 12 crash in event editor
                                StephenT Level 1 Level 1 (0 points)

                                One more detail: the crash only occurs in a release build. When running from the debugger in Xcode, everything works as expected.

                                  • Re: iOS 12 crash in event editor
                                    StephenT Level 1 Level 1 (0 points)

                                    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() {
                                            // Do any additional setup after loading the view.
                                        override func viewDidAppear(_ animated: Bool) {
                                            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 *.

                                • Re: iOS 12 crash in event editor
                                  andii Level 1 Level 1 (0 points)

                                  I've found another way to cause the crash without needing the event to be set to "all day". Setting the timezone to be "UTC" and commenting out `event.isAllDay = true` crashes the test app: https://github.com/ktakayama/EventKitUICrash/blob/master/EventKitUICrash/ViewController.swift


                                  Note my timezone is AEDT so timezones other then UTC might be needed to cause the crash for people in other timezones.


                                  Here is the repo code:

                                      // You should set different timezone from your system timezone.
                                      NSTimeZone.default = NSTimeZone(abbreviation: "UTC") as TimeZone!
                                      let store = EKEventStore()
                                      store.requestAccess(to: .event) { _, _ in
                                        let event = EKEvent(eventStore: store)
                                        event.startDate = Date() //calendar.date(from: components)
                                        event.endDate = Date() 
                                        event.timeZone = NSTimeZone.default
                                        //event.isAllDay = true
                                        let viewController = EKEventEditViewController()
                                        viewController.editViewDelegate = self
                                        viewController.eventStore = store
                                        viewController.event = event
                                        self.present(viewController, animated: true, completion: nil)
                                  • Re: iOS 12 crash in event editor
                                    bloemy7 Level 1 Level 1 (0 points)

                                    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.