Firebase App配置崩溃

时间:2016-10-24 18:35:31

标签: ios iphone swift firebase firebase-analytics

我有一个适用于iOS的自定义键盘,它使用Firebase进行分析。 Firebase应用程序配置在初始化程序中使用dispatch_once子句完成,并将令牌作为全局变量。

var token: dispatch_once_t = 0

class KeyboardViewController: UIInputViewController {
// ..
  override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
    super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    dispatch_once(&token) {
        FIRApp.configure()
    } // line 90
  }
// ..
}

这工作正常,但我收到许多崩溃报告,指出在配置应用程序时许多设备上崩溃。我被困了几天试图找出原因。以下是其中一个崩溃报告堆栈跟踪的一部分:

Exception Type:  EXC_CRASH (SIGQUIT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Signal: Quit: 3
Termination Reason: Namespace SIGNAL, Code 0x3
Terminating Process: launchd [1]
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x000000018fab6338 __semwait_signal_nocancel + 8
1   libsystem_c.dylib               0x000000018f9e20dc nanosleep$NOCANCEL + 200 (nanosleep.c:104)
2   libsystem_c.dylib               0x000000018fa0568c sleep$NOCANCEL + 44 (sleep.c:62)
3   libsystem_dnssd.dylib           0x000000018fa6e7d4 ConnectToServer + 832 (dnssd_clientstub.c:607)
4   libsystem_dnssd.dylib           0x000000018fa6ff44 DNSServiceCreateConnection + 76 (dnssd_clientstub.c:1785)
5   libsystem_network.dylib         0x000000018fb2d318 __nw_resolver_set_update_handler_block_invoke + 872 (resolver.m:1031)
6   libdispatch.dylib               0x000000018f9711c0 _dispatch_client_callout + 16 (object.m:455)
7   libdispatch.dylib               0x000000018f97e860 _dispatch_barrier_sync_f_invoke + 84 (queue.c:3457)
8   libsystem_network.dylib         0x000000018fb2ce78 nw_resolver_set_update_handler + 208 (resolver.m:1275)
9   SystemConfiguration             0x0000000190f8a16c __SCNetworkReachabilityRestartResolver + 260 (SCNetworkReachability.c:1711)
10  SystemConfiguration             0x0000000190f891c8 __SCNetworkReachabilitySetDispatchQueue + 764 (SCNetworkReachability.c:1823)
11  SystemConfiguration             0x0000000190f88ccc SCNetworkReachabilityScheduleWithRunLoop + 504 (SCNetworkReachability.c:1586)
12  CustomKeyboard              0x000000010013f630 -[FIRReachabilityChecker start] + 196
13  CustomKeyboard              0x000000010013abac -[FIRNetwork init] + 156
14  CustomKeyboard              0x0000000100132e28 -[FIRClearcutLogger init] + 416
15  CustomKeyboard              0x0000000100132c68 __35+[FIRClearcutLogger sharedInstance]_block_invoke + 36
16  libdispatch.dylib               0x000000018f9711c0 _dispatch_client_callout + 16 (object.m:455)
17  libdispatch.dylib               0x000000018f971fb4 dispatch_once_f + 56 (once.c:57)
18  CustomKeyboard              0x0000000100132c40 +[FIRClearcutLogger sharedInstance] + 108
19  CustomKeyboard              0x0000000100137214 +[FIRApp initClearcut] + 60
20  CustomKeyboard              0x0000000100136688 +[FIRApp configureDefaultAppWithOptions:sendingNotifications:] + 132
21  CustomKeyboard              0x000000010013643c +[FIRApp configure] + 316
22  libdispatch.dylib               0x000000018f9711c0 _dispatch_client_callout + 16 (object.m:455)
23  libdispatch.dylib               0x000000018f971fb4 dispatch_once_f + 56 (once.c:57)
24  CustomKeyboard              0x00000001000e314c _TFC19CustomKeyboard22KeyboardViewControllercfT7nibNameGSqSS_6bundleGSqCSo8NSBundle__S0_ + 1500 (KeyboardViewController.swift:90)
25  CustomKeyboard              0x00000001000e3270 _TToFC19CustomKeyboard22KeyboardViewControllercfT7nibNameGSqSS_6bundleGSqCSo8NSBundle__S0_ + 112 (KeyboardViewController.swift:0)
26  UIKit                           0x00000001971f7688 -[_UIViewServiceViewControllerOperator __createViewController:withContextToken:fbsDisplays:appearanceSerializedRepresentations:legacyAppearance:traitCollection:initialInterfaceOrientation:hostAccessibilityServerPort:canShowTextServices:replyHandler:] + 2216 (UIViewServiceViewControllerOperator.m:1732)
27  CoreFoundation                  0x0000000190aee160 __invoking___ + 144
28  CoreFoundation                  0x00000001909e1c3c -[NSInvocation invoke] + 284 (NSForwarding.m:2948)
29  CoreFoundation                  0x00000001909e66ec -[NSInvocation invokeWithTarget:] + 60 (NSForwarding.m:3019)

显然,调用FIRApp.configure()后的调用跟踪正在通过系统库。

堆栈跟踪的一个观察结果是崩溃与检查设备的可达性有关。但是,我尝试重现一个没有互联网连接的情况,但它工作正常。

请注意,所有崩溃都发生在iOS 10上,其中大多数都发生在iPhone 6上。

任何有助于找出崩溃原因的帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

建议不要在扩展程序中使用Firebase Analytics,因为SDK不支持扩展程序。与完整应用相比,应用扩展功能有限,因此Firebase Analytics在某些情况下可能无法正常运行,例如本网络中的网络。该团队正在考虑以后更好地支持扩展。

似乎Apple所述的自定义键盘上没有网络

  

“默认情况下,键盘没有网络访问权限且无法共享   包含app的容器。要启用这些功能,请设置   Info.plist文件中的RequestsOpenAccess Boolean键的值   是。这样做会扩展键盘的沙箱,如中所述   设计用户信任。“

https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/CustomKeyboard.html#//apple_ref/doc/uid/TP40014214-CH16-SW1