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

Improve ANR error message information #553

Merged
merged 9 commits into from
Aug 14, 2019
Merged

Conversation

fractalwrench
Copy link
Contributor

@fractalwrench fractalwrench commented Aug 6, 2019

Goal

Android records a cause for an ANR in the ProcessRecord for the app process. Adding the message to error reports will improve context and differentiate timed out input dispatching from failing to respond to a broadcast event.

Changeset

When SIGQUIT is caught bugsnag creates an Error which captures the stacktrace. Rather than sending this report immediately, the notifier now polls the ActivityManager for 30 seconds in an attempt to access process error information.

Once this information is available the notifier updates the error message to the value of ProcessErrorStateInfo#shortMsg, resulting in a stacktrace that looks like this:

ANR:  Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago.  Wait queue length: 24.  Wait queue head age: 6396.4ms.)
        at java.lang.Thread.sleep(Thread.java:-2)
        at java.lang.Thread.sleep(Thread.java:373)
        at java.lang.Thread.sleep(Thread.java:314)
        at com.bugsnag.android.example.ExampleActivity$onCreate$3.onClick(ExampleActivity.kt:38)
        at android.view.View.performClick(View.java:6256)

Important Note: Android has a concept of 'silent ANRs' which occur when the process is in the background. For silent ANRs, the process is killed immediately without showing a dialog to the user. With this changeset Bugsnag will no longer detect silent ANRs, which may reduce 'overreporting' that has been raised as feedback.

Other changes

  • Made it possible to set the name and message on a BugsnagException, and added public methods for doing this via the Error object also
  • Updated Error and Exceptions to always use a BugsnagException field. Regular Throwables are now wrapped into a BugsnagException

Tests

  • Added unit test coverage
  • Ran existing tests and manually tested ANR detection in example app

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shaping up nicely!

@fractalwrench fractalwrench force-pushed the anr-message-improvements branch 2 times, most recently from 5673b0a to b074b3f Compare August 7, 2019 14:46
@fractalwrench fractalwrench marked this pull request as ready for review August 8, 2019 09:50
Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changeset should bring the poll interval in AppNotRespondingMonitor down from 5s to 2s or so. In the worst case, the ANR dialog could pop before the details collector spins up (since it could be up to 5s after the ANR is initially detected).

@fractalwrench
Copy link
Contributor Author

@kattrali thanks for the review comments, I've updated the implementation and also added an ANR tab with a CPU Info key. The poll interval in AppNotRespondingMonitor has been left at 5ms.

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changeset should bring the poll interval in AppNotRespondingMonitor down from 5s to 2s or so. In the worst case, the ANR dialog could pop before the details collector spins up (since it could be up to 5s after the ANR is initially detected).

Copy link
Contributor

@kattrali kattrali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-person conversation

The current interval is 5ms not 5s, which is good.

@fractalwrench fractalwrench merged commit 41145c9 into next Aug 14, 2019
@fractalwrench fractalwrench deleted the anr-message-improvements branch August 14, 2019 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants