-
Notifications
You must be signed in to change notification settings - Fork 11
ANR based on ApplicationExitInfo #166
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 tasks
# Conflicts: # backtrace-library/build.gradle
melekr
approved these changes
May 7, 2025
melekr
approved these changes
May 7, 2025
backtrace-library/src/main/java/backtraceio/library/anr/BacktraceAppExitInfoSenderHandler.java
Outdated
Show resolved
Hide resolved
backtrace-library/src/main/java/backtraceio/library/anr/BacktraceAppExitInfoSenderHandler.java
Outdated
Show resolved
Hide resolved
backtrace-library/src/main/java/backtraceio/library/BacktraceClient.java
Show resolved
Hide resolved
backtrace-library/src/main/java/backtraceio/library/base/NativeLibraryLoader.java
Show resolved
Hide resolved
backtrace-library/src/main/java/backtraceio/library/common/SharedPreferencesManager.java
Outdated
Show resolved
Hide resolved
melekr
approved these changes
May 26, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new method for detecting Application Not Responding (ANR) events by utilizing the
ApplicationExitInfo
API, available in Android API level 30 (Android 11) and above. By leveraging this API, the Backtrace Android SDK can more accurately and efficiently detect ANR events, enhancing the reliability of application monitoring.Key Changes:
ANR Detection Enhancement: Implemented ANR detection based on
ApplicationExitInfo
, improving the accuracy of ANR reporting on devices running Android 11 and later.Backward Compatibility: Ensured that the existing ANR detection mechanisms remain functional for devices running Android versions prior to 11, maintaining broad compatibility across Android versions.
Code Refactoring: Refactored relevant components to integrate the new ANR detection method seamlessly, enhancing code maintainability and clarity.
Benefits:
This update provides developers with more precise ANR detection on newer Android devices, leading to better diagnostics and application performance insights. The integration of
ApplicationExitInfo
allows for a more standardized approach to ANR detection, aligning with modern Android development practices.How It Works
Now, users can choose their preferred ANR detection method. The Threshold method detects ANRs by monitoring the main application thread for freezes, while the ApplicationExit method relies on events from the Android API.
When using the ApplicationExit method, a background thread is spawned to process ANR events. This thread retrieves all recorded events, checks the last reported timestamp stored in
SharedPreferences
, and evaluates each event's type and timestamp. If an event has the typeREASON_CRASH
and its timestamp is more recent than the last recorded one, it is sent to the Backtrace API. Once sent, the timestamp is updated inSharedPreferences
. After processing all events, the background thread terminates.Docs PR: saucelabs/sauce-docs#3160


Example ANR error: https://yolo.sp.backtrace.io/api/share/1e88nzW5jOx3njx2gVZdooX3