diff --git a/Classes/BITCrashDetails.h b/Classes/BITCrashDetails.h index b9322f35f3..4cd8fb7321 100644 --- a/Classes/BITCrashDetails.h +++ b/Classes/BITCrashDetails.h @@ -1,10 +1,30 @@ -// -// BITCrashDetails.h -// HockeySDK -// -// Created by Andreas Linde on 03.04.14. -// -// +/* + * Author: Andreas Linde + * + * Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ #import @@ -50,13 +70,26 @@ */ @property (nonatomic, readonly, strong) NSString *appBuild; -- (instancetype)initWithIncidentIdentifier:(NSString *)incidentIdentifier - reporterKey:(NSString *)reporterKey - signal:(NSString *)signal - exceptionName:(NSString *)exceptionName - exceptionReason:(NSString *)exceptionReason - appStartTime:(NSDate *)appStartTime - crashTime:(NSDate *)crashTime - appBuild:(NSString *)appBuild; +/** + Indicates if the app was killed while being in foreground from the iOS + + If `[BITCrashManager enableAppNotTerminatingCleanlyDetection]` is enabled, use this on startup + to check if the app starts the first time after it was killed by iOS in the previous session. + + This can happen if it consumed too much memory or the watchdog killed the app because it + took too long to startup or blocks the main thread for too long, or other reasons. See Apple + documentation: https://developer.apple.com/library/ios/qa/qa1693/_index.html + + See `[BITCrashManager enableDectionAppKillWhileInForeground]` for more details about which kind of kills can be detected. + + @warning This property only has a correct value, once `[BITHockeyManager startManager]` was + invoked! In addition, it is automatically disabled while a debugger session is active! + + @see `[BITCrashManager enableAppNotTerminatingCleanlyDetection]` + @see `[BITCrashManager didReceiveMemoryWarningInLastSession]` + + @return YES if the details represent an app kill instead of a crash + */ +- (BOOL)isAppKill; @end diff --git a/Classes/BITCrashDetails.m b/Classes/BITCrashDetails.m index 187b7ba0bc..b7f5b52c84 100644 --- a/Classes/BITCrashDetails.m +++ b/Classes/BITCrashDetails.m @@ -1,12 +1,35 @@ -// -// BITCrashDetails.m -// HockeySDK -// -// Created by Andreas Linde on 03.04.14. -// -// +/* + * Author: Andreas Linde + * + * Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ #import "BITCrashDetails.h" +#import "BITCrashDetailsPrivate.h" + +NSString *const kBITCrashKillSignal = @"SIGKILL"; @implementation BITCrashDetails @@ -32,4 +55,13 @@ return self; } +- (BOOL)isAppKill { + BOOL result = NO; + + if (_signal && [[_signal uppercaseString] isEqualToString:kBITCrashKillSignal]) + result = YES; + + return result; +} + @end diff --git a/Classes/BITCrashDetailsPrivate.h b/Classes/BITCrashDetailsPrivate.h new file mode 100644 index 0000000000..6c6fa241a1 --- /dev/null +++ b/Classes/BITCrashDetailsPrivate.h @@ -0,0 +1,46 @@ +/* + * Author: Andreas Linde + * + * Copyright (c) 2012-2014 HockeyApp, Bit Stadium GmbH. + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#import + +extern NSString *const __attribute__((unused)) kBITCrashKillSignal; + +@interface BITCrashDetails () { + +} + +- (instancetype)initWithIncidentIdentifier:(NSString *)incidentIdentifier + reporterKey:(NSString *)reporterKey + signal:(NSString *)signal + exceptionName:(NSString *)exceptionName + exceptionReason:(NSString *)exceptionReason + appStartTime:(NSDate *)appStartTime + crashTime:(NSDate *)crashTime + appBuild:(NSString *)appBuild; + +@end diff --git a/Classes/BITCrashManager.h b/Classes/BITCrashManager.h index 49e32601c5..6cb8033a66 100644 --- a/Classes/BITCrashManager.h +++ b/Classes/BITCrashManager.h @@ -259,7 +259,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) { * @warning This is a heuristic and it _MAY_ report false positives! It has been tested with iOS 6.1 and iOS 7. * Depending on Apple changing notification events, new iOS version may cause more false positives! * - * @see wasKilledInLastSession + * @see lastSessionCrashDetails * @see didReceiveMemoryWarningInLastSession * @see `BITCrashManagerDelegate considerAppNotTerminatedCleanlyReportForCrashManager:` * @see [Apple Technical Note TN2151](https://developer.apple.com/library/ios/technotes/tn2151/_index.html) @@ -325,6 +325,8 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) { @warning This property only has a correct value, once `[BITHockeyManager startManager]` was invoked! + + @see lastSessionCrashDetails */ @property (nonatomic, readonly) BOOL didCrashInLastSession; @@ -349,27 +351,6 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) { */ - (void) setAlertViewHandler:(BITCustomAlertViewHandler)alertViewHandler; -/** - Indicates if the app was killed while being in foreground from the iOS - - If `enableAppNotTerminatingCleanlyDetection` is enabled, use this on startup to check if the - app starts the first time after it was killed by iOS in the previous session. - - This can happen if it consumed too much memory or the watchdog killed the app because it - took too long to startup or blocks the main thread for too long, or other reasons. See Apple - documentation: https://developer.apple.com/library/ios/qa/qa1693/_index.html - - See `enableDectionAppKillWhileInForeground` for more details about which kind of kills can be detected. - - @warning This property only has a correct value, once `[BITHockeyManager startManager]` was - invoked! In addition, it is automatically disabled while a debugger session is active! - - @see enableAppNotTerminatingCleanlyDetection - @see didReceiveMemoryWarningInLastSession - */ -@property (nonatomic, readonly) BOOL wasKilledInLastSession; - - /** * Provides details about the crash that occured in the last app session */ @@ -392,7 +373,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) { invoked! @see enableAppNotTerminatingCleanlyDetection - @see wasKilledInLastSession + @see lastSessionCrashDetails */ @property (nonatomic, readonly) BOOL didReceiveMemoryWarningInLastSession; diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 7ac9094c36..33a8fff617 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -43,6 +43,7 @@ #import "BITHockeyBaseManagerPrivate.h" #import "BITCrashManagerPrivate.h" #import "BITCrashReportTextFormatter.h" +#import "BITCrashDetailsPrivate.h" #include @@ -1056,7 +1057,6 @@ static PLCrashReporterCallbacks plCrashCallbacks = { if (considerReport) { [self createCrashReportForAppKill]; - _wasKilledInLastSession = YES; _didCrashInLastSession = YES; } } @@ -1084,7 +1084,7 @@ static PLCrashReporterCallbacks plCrashCallbacks = { NSString *fakeReportDeviceModel = [self getDevicePlatform] ?: @"Unknown"; NSString *fakeReportAppUUIDs = [[NSUserDefaults standardUserDefaults] objectForKey:kBITAppUUIDs] ?: @""; - NSString *fakeSignalName = @"SIGKILL"; + NSString *fakeSignalName = kBITCrashKillSignal; NSMutableString *fakeReportString = [NSMutableString string]; diff --git a/Support/HockeySDK.xcodeproj/project.pbxproj b/Support/HockeySDK.xcodeproj/project.pbxproj index 13d4da6796..e2f862b2ac 100644 --- a/Support/HockeySDK.xcodeproj/project.pbxproj +++ b/Support/HockeySDK.xcodeproj/project.pbxproj @@ -129,6 +129,7 @@ 1EAF20AA162DC0F600957B1D /* feedbackActiviy.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EAF20A6162DC0F600957B1D /* feedbackActiviy.png */; }; 1EAF20AB162DC0F600957B1D /* feedbackActiviy@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1EAF20A7162DC0F600957B1D /* feedbackActiviy@2x.png */; }; 1EB52FD5167B766100C801D5 /* HockeySDK.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1E59555F15B6F80E00A03429 /* HockeySDK.strings */; }; + 1ECA8F4D192B5BD8006B9416 /* BITCrashDetailsPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ECA8F4B192B5BD8006B9416 /* BITCrashDetailsPrivate.h */; }; 1ED570C718BF878C00AB3350 /* BITCrashAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ED570C518BF878C00AB3350 /* BITCrashAttachment.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1ED570C818BF878C00AB3350 /* BITCrashAttachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ED570C618BF878C00AB3350 /* BITCrashAttachment.m */; }; 1EF95CA6162CB037000AE3AD /* BITFeedbackActivity.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EF95CA4162CB036000AE3AD /* BITFeedbackActivity.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -289,6 +290,7 @@ 1EAF20A6162DC0F600957B1D /* feedbackActiviy.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = feedbackActiviy.png; sourceTree = ""; }; 1EAF20A7162DC0F600957B1D /* feedbackActiviy@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "feedbackActiviy@2x.png"; sourceTree = ""; }; 1EB52FC3167B73D400C801D5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/HockeySDK.strings; sourceTree = ""; }; + 1ECA8F4B192B5BD8006B9416 /* BITCrashDetailsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITCrashDetailsPrivate.h; sourceTree = ""; }; 1ED570C518BF878C00AB3350 /* BITCrashAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BITCrashAttachment.h; sourceTree = ""; }; 1ED570C618BF878C00AB3350 /* BITCrashAttachment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BITCrashAttachment.m; sourceTree = ""; }; 1EDA60CF15C2C1450032D10B /* HockeySDK-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HockeySDK-Info.plist"; sourceTree = ""; }; @@ -488,6 +490,7 @@ 1E754E571621FBB70070AB92 /* BITCrashManager.m */, 1E90FD7118EDB86400CF0417 /* BITCrashDetails.h */, 1E90FD7218EDB86400CF0417 /* BITCrashDetails.m */, + 1ECA8F4B192B5BD8006B9416 /* BITCrashDetailsPrivate.h */, 1EFF03D717F20F8300A5F13C /* BITCrashManagerPrivate.h */, 1E754E581621FBB70070AB92 /* BITCrashManagerDelegate.h */, 1ED570C518BF878C00AB3350 /* BITCrashAttachment.h */, @@ -652,6 +655,7 @@ 1E49A44E1612223B00463151 /* BITFeedbackManager.h in Headers */, E4B4DB7D17B435550099C67F /* BITAuthenticationViewController.h in Headers */, 1E49A4481612223B00463151 /* BITFeedbackListViewController.h in Headers */, + 1ECA8F4D192B5BD8006B9416 /* BITCrashDetailsPrivate.h in Headers */, 1E49A47F1612226D00463151 /* BITUpdateViewController.h in Headers */, 1E49A43C1612223B00463151 /* BITFeedbackComposeViewController.h in Headers */, E40E0B0C17DA1AFF005E38C1 /* BITHockeyAppClient.h in Headers */,