2 Replies
      Latest reply on Aug 7, 2019 1:39 PM by robotspacer
      sanjay Level 1 Level 1 (0 points)

        EKEventStore methods sometimes return fewer calendars or events than expected.

         

        I allocate an EKEventStore and query it for calendars and events. I also register for various notifications, including EKEventStoreChangedNotification, and re-query the store when those notifications are observed.

         

        I have 10 calendars of which 4 are Google calendars. The following call always returns all 10 when first queried and usually returns all 10 on subsequent queries:

         

            NSArray *calendars = [_eventStore calendarsForEntityType:EKEntityTypeEvent];

         

        However, sometimes it will return 6 or 7 calendars. The missing 3 or 4 calendars are always my Google calendars.

         

        I have the same issue with the following call:

         

            NSArray *events = [_eventStore eventsMatchingPredicate:predicate];

         

        It always returns all events when first queried and usually returns all events on subsequent queries, but sometimes will return fewer than expected events for my Google calendars.

         

        Some users of my app have also reported this issue to me so it is not unique to my calendars.

         

        The only way to "fix" the issue is to either wait an indefinite amount of time, after which the above calls will again return the expected calendars and events, or to completely start over by re-allocating a new store. Of course, neither is a good solution.

         

        What is happening? I think this is a bug in EKEventStore, but I can't write a good Radar since it happens intermittently and is thus impossible to reliably replicate. The code where this is happening is here: https://github.com/sfsam/Itsycal/blob/master/Itsycal/EventCenter.m

        • Re: Event store intermittently loses calendars and events
          robotspacer Level 1 Level 1 (10 points)

          I don't have much to add, but the same thing seems to be happening in my app, for at least one of my customers. They're using Google Calendar as well, and on a Mac.

           

          I'm currently doing some testing to see if I can recreate the bug. I'm expecting it to take a while—when I asked my customer to try to recreate it to gather some logs, it took two weeks.

           

          I'd say it's worth filing a bug even if you don't have all the details, especially if you have sample code you can share. It may be helpful if you run a sysdiagnose as soon as possible after you notice the problem.

           

          When the problem does happen for you, about how long does it usually take for the missing calendars to reappear? Minutes? Hours? Days? My tentative plan to work around the problem is to just keep trying periodically until the missing calendar reppears. If it takes more than a day or so, then give up.

            • Re: Event store intermittently loses calendars and events
              robotspacer Level 1 Level 1 (10 points)

              Just wanted to add some follow up information: I haven't been able to reproduce the problem myself, but for my customer it seems the missing calendar returns less than an hour later. In one case it was missing at 11:06, still missing at 11:19, then returned at 11:44. The calendar still had the same identifier when it reappeared, so in my app that made it easy to work around the problem.