-
Notifications
You must be signed in to change notification settings - Fork 14
Feature/crash loop detection #80
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
9898625
5528917
74c574c
6aa61c1
6f67d1f
ff7cf06
3480c11
a069cca
cac04c1
483f630
9f6b1c8
017ff99
67a92a3
a156236
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,3 +89,5 @@ hs_err_pid* | |
| obj/ | ||
| .externalNativeBuild | ||
| **/.cxx | ||
|
|
||
| backtrace-library/src/main/jniLibs/** | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ extern std::atomic_bool disabled; | |
| static crashpad::CrashpadClient *client; | ||
| static std::unique_ptr<crashpad::CrashReportDatabase> database; | ||
|
|
||
| static int consecutive_crashes_count = 0; | ||
|
|
||
| bool InitializeCrashpad(jstring url, | ||
| jstring database_path, | ||
| jstring handler_path, | ||
|
|
@@ -19,6 +21,7 @@ bool InitializeCrashpad(jstring url, | |
| jobjectArray attachmentPaths, | ||
| jboolean enableClientSideUnwinding, | ||
| jint unwindingMode) { | ||
|
|
||
|
konst-sauce marked this conversation as resolved.
Outdated
|
||
| // avoid multi initialization | ||
| if (initialized) { | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad is already initialized"); | ||
|
|
@@ -120,9 +123,12 @@ bool InitializeCrashpad(jstring url, | |
|
|
||
| // Start crash handler | ||
| client = new crashpad::CrashpadClient(); | ||
| client->EnableCrashLoopDetection(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we want to make this configurable for the end-users.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we should - imo we should pass it and don't execute this path if we don't need it. By default we want have features opt-in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed it - it is called from Example's MainActivity now. |
||
|
|
||
| initialized = client->StartHandlerAtCrash(handler, db, db, backtraceUrl, attributes, | ||
| arguments); | ||
| // Get consecutive crashes count BEFORE any handler started, | ||
| // as it writes extra line into CSV, what leads to getting 0 for each next ConsecutiveCrashesCount call | ||
| consecutive_crashes_count = crashpad::CrashpadClient::ConsecutiveCrashesCount(db); | ||
|
konst-sauce marked this conversation as resolved.
|
||
| initialized = client->StartHandlerAtCrash(handler, db, db, backtraceUrl, attributes, arguments); | ||
|
|
||
| env->ReleaseStringUTFChars(url, backtraceUrl); | ||
| env->ReleaseStringUTFChars(handler_path, handlerPath); | ||
|
|
@@ -219,10 +225,27 @@ void ReEnableCrashpad() { | |
| // Re-enable uploads if disabled | ||
| if (disabled) { | ||
| if (database == nullptr) { | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad database is null, this should not happen"); | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", | ||
| "Crashpad database is null, this should not happen"); | ||
| return; | ||
| } | ||
| database->GetSettings()->SetUploadsEnabled(true); | ||
| disabled = false; | ||
| } | ||
| } | ||
|
|
||
| bool EnableCrashLoopDetectionCrashpad() { | ||
|
konst-sauce marked this conversation as resolved.
|
||
| if (client != nullptr) { | ||
| return client->EnableCrashLoopDetection(); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| bool IsSafeModeRequiredCrashpad() { | ||
| return consecutive_crashes_count >= 5; | ||
| } | ||
|
|
||
| int ConsecutiveCrashesCountCrashpad() { | ||
| return consecutive_crashes_count; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.