Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to report crash on launch #597

Closed
3 of 9 tasks
CX3201 opened this issue Jul 1, 2020 · 8 comments
Closed
3 of 9 tasks

How to report crash on launch #597

CX3201 opened this issue Jul 1, 2020 · 8 comments

Comments

@CX3201
Copy link

CX3201 commented Jul 1, 2020

Platform:

  • iOS
  • tvOS
  • MacOS
  • watchOS

Swift:

  • Yes -> If yes, which version?
  • No

sentry-cocoa installed with:

  • CocoaPods
  • Carthage
  • Manually

Version of sentry-cocoa:
5.1.6


I have following issue:

I write the following code to raise an exception, but the crash never reported. Is there any way to do this?

Steps to reproduce:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
        options.dsn = @"___PUBLIC_DSN___";
        options.debug = @YES; // Helpful to see what's going on
    }];
    [SentrySDK crash];
    return YES;
}

Actual result:

  • Actual

Expected result:

  • Result
@philipphofmann
Copy link
Member

@CX3201, did you replace ___PUBLIC_DSN___ with your DSN that you get from Sentry? If not please do so. If so, please check your log output, because it can be that the DSN is not valid.

@CX3201
Copy link
Author

CX3201 commented Jul 2, 2020

@CX3201, did you replace ___PUBLIC_DSN___ with your DSN that you get from Sentry? If not please do so. If so, please check your log output, because it can be that the DSN is not valid.

Yes, I did. I think the resaon is the report request doesn't have enough time to send. Is there any sync method?

@philipphofmann
Copy link
Member

Please don't call [SentrySDK crash]; directly after our SDK start and also not in didFinishLaunchingWithOptions. Instead, call it when the app is fully launched or even better call it when you click a button.
When a hard crash happens our SDK stores the crash on the disk. The next time the SDK is launched we read it from the disk and send it to Sentry. Right now the SDK hasn't enough time to do that, because your implementation always crashes directly after our SDK is started.

@CX3201
Copy link
Author

CX3201 commented Jul 3, 2020

Please don't call [SentrySDK crash]; directly after our SDK start and also not in didFinishLaunchingWithOptions. Instead, call it when the app is fully launched or even better call it when you click a button.
When a hard crash happens our SDK stores the crash on the disk. The next time the SDK is launched we read it from the disk and send it to Sentry. Right now the SDK hasn't enough time to do that, because your implementation always crashes directly after our SDK is started.

That means Sentry will never send report if the app crashes directly in didFinishLaunchingWithOptions. Is there something I can do to collect those exceptions?

@philipphofmann
Copy link
Member

Sentry most likely will never send the report if the app always crashes in didFinishLaunchingWithOptions, because it doesn't get enough time to send the report. If it only happens a few times Sentry writes the error to the disk and sends it the next time.

@CX3201
Copy link
Author

CX3201 commented Jul 3, 2020

Sentry most likely will never send the report if the app always crashes in didFinishLaunchingWithOptions, because it doesn't get enough time to send the report. If it only happens a few times Sentry writes the error to the disk and sends it the next time.

Thanks

@CX3201 CX3201 closed this as completed Jul 3, 2020
@bb-git
Copy link

bb-git commented Nov 29, 2021

It would make sense to block app launch and send the crash first!

@philipphofmann
Copy link
Member

@bb-git, agree see #316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants