bitstadium / HockeySDK-iOS

HockeyApp was retired and the SDKs are deprecated. Please use App Center instead.
https://github.com/microsoft/appcenter-sdk-apple
Other
597 stars 268 forks source link

AppNotTerminatingCleanly event is not reported after process start #539

Closed damirdavletov closed 5 years ago

damirdavletov commented 5 years ago

Steps to reproduce:

  1. Start the app process (In appDidFinishLaunching start HockeyApp manager)
  2. Trigger out-of-memory crash
  3. Restart the app Actual result: No SIGKILL in the dashboard Expected result: SIGKILL appeared in the dashboard

Note: for all other cases e.g. fold/unfold the app then trigger crash everything is getting reported as expected.

Pull request for the fix #538

thyeggman commented 5 years ago

Hi @damirdavletov!

I can't try to reproduce this without knowing some more information first.

  1. What version of the SDK are you using?
  2. Is the crash being triggered from a foreground thread or a background thread?
  3. How are you using AppNotTerminatingCleanly? I’m assuming you have enabled it by calling enableAppNotTerminatingCleanlyDetection. It's a heuristic that doesn't indicate when an app has crashed, only when the app is killed by the user on a foreground thread or by the iOS watchdog.

If you are willing to provide the offending code snippet, it would help diagnose the issue as well. Once we have identified a problem we can consider merging your PR.

damirdavletov commented 5 years ago

Hi @jwallra!

  1. What version of the SDK are you using?

We were using 4.1.6 the issue was initially found there, then we upgraded to 5.1.4 and the problem is there as well.

  1. Is the crash being triggered from a foreground thread or a background thread?

The SIGKILL is being triggered from main thread when that app is running in foreground with the following code:

- (void)triggerOOMCrash {
    UILabel *label = [[UILabel alloc] initWithFrame:[[[UIApplication sharedApplication] keyWindow] bounds]];
    label.text = @"Crashing With OOM";
    [[[UIApplication sharedApplication] keyWindow] addSubview:label];
    dispatch_async(dispatch_get_main_queue(), ^{
        [self triggerOOMCrash];
    });
}
  1. How are you using AppNotTerminatingCleanly? I’m assuming you have enabled it by calling enableAppNotTerminatingCleanlyDetection. It's a heuristic that doesn't indicate when an app has crashed, only when the app is killed by the user on a foreground thread or by the iOS watchdog.

If you are willing to provide the offending code snippet, it would help diagnose the issue as well. Once we have identified a problem we can consider merging your PR.

We have been using AppNotTerminatingCleanly feature for years it is very useful and we know how it works. Not sure what you mean by offending code snippet but here is how HockeyApp is set up:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...

    [[BITHockeyManager sharedHockeyManager] configureWithBetaIdentifier:hockeyAppBetaIdentifier liveIdentifier:hockeyAppIdentifier delegate:self];

    BITCrashManagerCallbacks crashCallbacks;
    crashCallbacks.context = NULL;
    crashCallbacks.handleSignal = postCrashSignalCallback;
    [[[BITHockeyManager sharedHockeyManager] crashManager] setCrashCallbacks:&crashCallbacks];
    [[BITHockeyManager sharedHockeyManager] crashManager].crashManagerStatus = BITCrashManagerStatusAutoSend;
    [[BITHockeyManager sharedHockeyManager] crashManager].enableAppNotTerminatingCleanlyDetection = YES;
    [[BITHockeyManager sharedHockeyManager] startManager];
    ..
}
thyeggman commented 5 years ago

@damirdavletov Thanks for the detailed information. I'll try to verify the issue and fix, and then we'll look at merging it.

thyeggman commented 5 years ago

@damirdavletov We've merged your PR. Thanks for the contribution!