首页 > 解决方案 > Crashlytics 未将崩溃事件传输到 Fabric.io(仅限调试模式?)

问题描述

我遇到了类似于 [ xCode 9.3 and Firebase Crashlytics not working的问题。我能够在主应用程序的调试版本中强制崩溃,并且崩溃出现在 Fabric.io 的控制台中。我还提出了一种方法(使用“复活节彩蛋”)来强制框架代码崩溃。我尝试了三种不同的方法。前两个尝试模拟源自框架代码本身的“真实”崩溃。第三个对主应用程序使用“虚假”回调。请注意,在下面的代码中,我将所有三种方法一起展示,但在现实生活中,我将其中两种方法注释掉以测试一种方法:

//#1
@throw ([NSException exceptionWithName:@"CrashlyticsForce" reason:@"Easter egg hit" userInfo:nil]);

//#2
NSDecimalNumber *i = [NSDecimalNumber decimalNumberWithDecimal:[@(1) decimalValue]];
NSDecimalNumber *o = [NSDecimalNumber decimalNumberWithDecimal:[@(0) decimalValue]];
// Divide by 0 to throw an exception
NSDecimalNumber *x = [i decimalNumberByDividingBy:o];    

//#3 The following DOES work, but it's really lame because the crash
// actually gets forced in the main app via this bogus call to a
// protocol method implemented in the app for the sole purpose of
// enabling the engine to force a crash.
[(NSObject <NSAlertDelegate> *)[NSApp delegate] alertShowHelp:
[NSAlert alertWithMessageText:@"Forcing an error" defaultButton:nil
alternateButton:nil otherButton:nil
informativeTextWithFormat:@"Forcing error from framework!"]];

NSLog(@"Crashlytics - KME: You should not be seeing this line!");

对于第三种方法,主应用程序通过调用处理回调

[[Crashlytics sharedInstance] crash];

使用方法 #3 时,Crashlytics 立即将模拟崩溃上传到 Fabric.io 控制台,我可以在其中看到。失败的方法没有。目前尚不清楚它们是否真的导致应用程序崩溃,尽管控制确实离开了该方法(因为最终的 NSLog 语句从未出现在控制台中。该应用程序是一个输入法,因此操作系统可能会自动重新启动它。我尝试重新启动计算机在强制崩溃后立即发生,因为我知道通常 Crashlytics 在重新启动应用程序之前不会传输崩溃。当我这样做时,我会在重新启动应用程序时在控制台中看到以下内容:

[Crashlytics] Version 3.10.1 (129)
[Crashlytics] Running on MacBookPro11,4, 10.13.4 (17E202)
[Answers] Initialized
[Fabric] Initialized with kit versions: {
    "com.twitter.answers.mac" = "1.3.7";
    "com.twitter.crashlytics.mac" = "3.10.1";
    "io.fabric.sdk.mac" = "1.7.6";
}
Faulting in NSHTTPCookieStorage singleton
Faulting in CFHTTPCookieStorage singleton
Creating default cookie storage with process/bundle identifier
Initializing Keyman Input Method with server: <IMKServer: 0x6040000147b0>
TIC Enabling TLS [1:0x6040001717c0]
TIC TCP Conn Start [1:0x6040001717c0]
Task <3C62019C-7486-469F-B4AE-9D4DDC7DB101>.<1> setting up Connection 1
[1 <private> <private>] start
New active app com.lastpass.LastPass
sender <IPMDServerClientWrapper: 0x6080002805f0>
TIC TLS Event [1:0x6040001717c0]: 1, Pending(0)
TIC TLS Event [1:0x6040001717c0]: 2, Pending(0)
UNIX error exception: 17
UNIX error exception: 17
UNIX error exception: 17
TIC TLS Event [1:0x6040001717c0]: 11, Pending(0)
TIC TLS Event [1:0x6040001717c0]: 12, Pending(0)
TIC TLS Event [1:0x6040001717c0]: 14, Pending(0)
System Trust Evaluation yielded status(0)
TIC TLS Trust Result [1:0x6040001717c0]: 0
TIC TLS Event [1:0x6040001717c0]: 20, Pending(0)
TIC TCP Conn Connected [1:0x6040001717c0]: Err(16)
TIC TCP Conn Event [1:0x6040001717c0]: 1
TIC TCP Conn Event [1:0x6040001717c0]: 8
TIC TLS Handshake Complete [1:0x6040001717c0]
Task <3C62019C-7486-469F-B4AE-9D4DDC7DB101>.<1> now using Connection 1
Task <3C62019C-7486-469F-B4AE-9D4DDC7DB101>.<1> sent request, body N
Task <3C62019C-7486-469F-B4AE-9D4DDC7DB101>.<1> received response, status 200 content K
Task <3C62019C-7486-469F-B4AE-9D4DDC7DB101>.<1> response ended
[Fabric] settings downloaded successfully
[Fabric] Settings are available for consumption
TIC TCP Conn Cancel [1:0x6040001717c0]
[1 <private> stream, pid: 649, url: https://settings.crashlytics.com/spi/v2/platforms/mac/apps/keyman.inputmethod.Keyman/settings?build_version=10.0.0&display_version, tls] cancelled
    [1.1 074D1109-26C9-44B8-834C-F53EF153DACA <private>.49357<-><private>]
    Connected Path: satisfied (Path is satisfied), interface: en0, ipv4, dns
    Duration: 0.218s, DNS @0.000s took 0.020s, TCP @0.024s took 0.023s, TLS took 0.123s
    bytes in/out: 7265/1338, packets in/out: 9/3, rtt: 0.019s, retransmitted packets: 0, out-of-order packets: 0
2018-05-25 10:43:13.267599 -0400    Keyman  [Answers] Answers enabled with settings: {
    "flush_interval_secs" = 300;
    "flush_on_background" = 1;
    "forward_to_google_analytics" = 0;
    "include_purchase_events_in_forwarded_events" = 0;
    "max_byte_size_per_file" = 8000;
    "max_file_count_per_send" = 1;
    "max_pending_send_file_count" = 100;
    "sampling_rate" = 1;
    "track_custom_events" = 1;
    "track_predefined_events" = 1;
    "track_view_controllers" = 0;
    url = "https://e.crashlytics.com/spi/v2/events";
}
[Answers] Logging events to /Users/tom/Library/Caches/com.crashlytics.data/keyman.inputmethod.Keyman/analytics/v2/events
[Answers] Transmitting packaged events for '87099A49-DC62-4E10-AB2D-A98394173E21'.
TIC Enabling TLS [2:0x60c000171340]
TIC TCP Conn Start [2:0x60c000171340]
Task <CCB3C9EE-3123-42F8-A98D-D009EBF34DEB>.<1> setting up Connection 2
[2 <private> <private>] start
TIC TLS Event [2:0x60c000171340]: 1, Pending(0)
TIC TLS Event [2:0x60c000171340]: 2, Pending(0)
TIC TLS Event [2:0x60c000171340]: 11, Pending(0)
TIC TLS Event [2:0x60c000171340]: 12, Pending(0)
TIC TLS Event [2:0x60c000171340]: 14, Pending(0)
System Trust Evaluation yielded status(0)
TIC TLS Trust Result [2:0x60c000171340]: 0
TIC TLS Event [2:0x60c000171340]: 20, Pending(0)
TIC TCP Conn Connected [2:0x60c000171340]: Err(16)
TIC TCP Conn Event [2:0x60c000171340]: 1
TIC TCP Conn Event [2:0x60c000171340]: 8
TIC TLS Handshake Complete [2:0x60c000171340]
Task <CCB3C9EE-3123-42F8-A98D-D009EBF34DEB>.<1> now using Connection 2
Task <CCB3C9EE-3123-42F8-A98D-D009EBF34DEB>.<1> sent request, body S
Task <CCB3C9EE-3123-42F8-A98D-D009EBF34DEB>.<1> received response, status 200 content K
Task <CCB3C9EE-3123-42F8-A98D-D009EBF34DEB>.<1> response ended
[Answers] Finished transmission of '87099A49-DC62-4E10-AB2D-A98394173E21'.
LSExceptions shared instance invalidated for timeout.

在应用程序的生产版本中,我Fabric.io 上看到框架代码中发生的真正崩溃。生产版本使用不同的 API 代码,它内置于发布而不是调试,但我认为我对调试和发布的所有符号剥离和 dSYM 创建设置都相同。此外,FWIW,我尝试使用 #1 和 #2 代码强制在主应用程序的回调中崩溃(而不是调用 [[Crashlytics sharedInstance] crash]),并且 Crashlytics 也不会从那里报告它。所以它似乎与框架本身没有任何关系。

标签: macosframeworkscrashlyticsfabric.io

解决方案


推荐阅读