iosapple-watchapple-watch-complicationtime-travelclockkit

ClockKit CLKComplicationDataSource missing backward events


I write a test app with complications support

For some reason clock faces presenting only 1-2 backward events, but I can see in logs 10-15 events before current date. And when I return an empty array for forward events all my backward events start showing in clock face.

Here is my function

func getTimelineEntriesForComplication(complication: CLKComplication, beforeDate date: NSDate, limit: Int, withHandler handler: (([CLKComplicationTimelineEntry]?) -> Void)) {

    var entries: [CLKComplicationTimelineEntry] = []

    let events = self.events.filter { (event: CEEvent) -> Bool in
        return date.compare(event.startDate) == .OrderedDescending
    }

    var lastDate = date.midnightDate

    for event in events {
        let entry = CLKComplicationTimelineEntry(date: lastDate, complicationTemplate: event.getComplicationTemplate(complication.family))

        if let endDate = event.endDate {
            lastDate = endDate
        } else {
            lastDate = event.startDate
        }

        entries.append(entry)

        if entries.count >= limit {
            break
        }
    }

    handler(entries)
}

P.S. I know about 'limit' parameter and it's always greater than my array's count

P.P.S. Sorry about my English :)


Solution

  • I've seen that identical behavior for watchOS 2.0.1 where time travel backwards initially only shows two earlier entries, even though the datasource was asked for and returned 100 entries.

    About 15 minutes after launch, more entries started appearing for backwards time travel. About 30 minutes after launch, all 100 prior entries were present.

    This was not due to any update I scheduled, as my complication's update interval is 24 hours.

    It appears that the complication server prioritizes adding the forward entries, but defers populating the cache with all the backward time travel entries. You'd have to ask Apple whether it's an optimization or a bug.

    I don't know if this is a coincidence, but my timeline entries are spaced 15 minutes apart. Perhaps when the complication server updates the complication to show the new timeline entry, it also adds more of the batched earlier entries?