【问题标题】:How to debug and reproduce `NSOperationQueue` crash如何调试和重现“NSOperationQueue”崩溃
【发布时间】:2016-11-22 13:27:41
【问题描述】:

在我的基于日历的应用程序中,我遇到了来自应用程序商店构建的大量崩溃。但是,我无法重现,也没有遇到这种开发崩溃。

Fabric 的崩溃日志:

-[EKEventStore(Utils) calendarByRetrievingSafelyWithIdentifier:forEntityType:]

    Crashed: NSOperationQueue 0x17403fd60 :: NSOperation 0x17425bfc0 (QOS: DEFAULT)
0  CoreFoundation                 0x19179b5d8 -[__NSDictionaryM setObject:forKey:] + 476
1  EventKit                       0x19ab2a0d8 -[EKObject relationForKey:] + 216
2  EventKit                       0x19ab859d4 -[EKCalendar source] + 24
3  EventKit                       0x19ab9d718 -[EKEventStore calendarsForEntityType:] + 512
4  SampleApp                       0x100112554 -[EKEventStore(Utils) calendarByRetrievingSafelyWithIdentifier:forEntityType:] (MySampleCalendarStore.m:4767)
5  SampleApp                       0x1001d3f88 -[MyCalendarDataStore syncCalendarItems:startDate:endDate:completion:] (MyCalendarDataStore.m:84)
6  SampleApp                       0x1000f4e58 __62-[MySampleAppStore syncDeviceCalendarsAndItems:withCompletion:]_block_invoke.1043 (MySampleCalendarStore.m:2499)
7  Foundation                     0x19237e754 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16
8  Foundation                     0x1922c32c8 -[NSBlockOperation main] + 96
9  Foundation                     0x1922b38c4 -[__NSOperationInternal _start:] + 620
10 Foundation                     0x192380b00 __NSOQSchedule_f + 228
11 libdispatch.dylib              0x1907451c0 _dispatch_client_callout + 16
12 libdispatch.dylib              0x190753444 _dispatch_queue_serial_drain + 928
13 libdispatch.dylib              0x1907489a8 _dispatch_queue_invoke + 652
14 libdispatch.dylib              0x19075538c _dispatch_root_queue_drain + 572
15 libdispatch.dylib              0x1907550ec _dispatch_worker_thread3 + 124
16 libsystem_pthread.dylib        0x19094e2b8 _pthread_wqthread + 1288
17 libsystem_pthread.dylib        0x19094dda4 start_wqthread + 4

我想修复这个崩溃,上周我尝试了所有论坛。我找不到任何有用的线索来解决我的问题。 请指导我手动重现此类崩溃并帮助解决。

我的代码:

NSOperationQueue *calendarDataStoresQueue = [[NSOperationQueue alloc] init];
for (EKCalendar *calendar in calendars) {
        [calendarDataStoresQueue addOperationWithBlock:^{
            MyCalendarDataStore *calendarDataStore = [[MyCalendarDataStore alloc] initWithCalendar:[[MYCalendar alloc] initWithInfoOfEventKitCalendar:calendar] eventStore:weakSelf.eventStore];
            [calendarDataStore syncCalendarItems:items startDate:syncFrom endDate:syncTo completion:^{
                complition()
            }];
        }];
}

我的实用程序:

@implementation EKEventStore (Utils)

- (EKCalendar*)calendarByRetrievingSafelyWithIdentifier:(NSString *)identifier forEntityType:(EKEntityType)entityType {
    EKCalendar *calendar;
    NSArray *calendars = [self calendarsForEntityType:entityType];
    for (EKCalendar *aCalendar in calendars) {
        if([aCalendar.calendarIdentifier isEqualToString:identifier]) {
            calendar = aCalendar;
            break;
        }

    }
    return calendar;
}
@end

提前谢谢

【问题讨论】:

  • 你试过Exception Breakpoint 吗?
  • 是的,我已经检查过了,仍然没有运气。

标签: ios objective-c crash nsoperationqueue eventkit


【解决方案1】:

您没有发布足够的信息;你在 -[EKObject relationForKey:] 方法的某个地方发生了崩溃;更重要的是,您还没有发布崩溃的确切原因;

在我看来,这个方法 [EKObject relationForKey:] 在某处从自身生成 dict,并且可能是 [__NSDictionaryM setObject:forKey:] 在这里你尝试将 nil 插入到 dict 中

【讨论】:

  • 请检查崩溃日志 "3 EventKit 0x19ab9d718 -[EKEventStore calendarsForEntityType:] + 512" 。我在我的问题中给出了这段代码,毕竟这都是 eventKit 框架函数。
  • 是的,我已经完成了,但它不包含必要的信息;你能发布你的面料页面的屏幕截图吗?
  • 请检查崩溃日志 "3 EventKit 0x19ab9d718 -[EKEventStore calendarsForEntityType:] + 512" 。我在我的问题中给出了这段代码,毕竟这都是 eventKit 框架函数
  • 我猜不出这个框架中有什么,但我可以看到你崩溃的屏幕,它可能会有所帮助,所以请你提供它:)
  • 如果我也共享屏幕,您只会得到相同的日志。因为此信息在 crashlytics 中可用。如果日志中有足够多的信息,我会修复我自己。所以,第一个我需要重现像“NSOperationQueue(QOS:DEFAULT)”这样的崩溃
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多