Closed kylannjohnson closed 1 year ago
@kylannjohnson the problem is due to using both Crashlytics and Sentry alongside each other. Because Crashlytics is initialized first, its exception handler will be invoked before ours; they have a default timeout of 3 seconds (used to be 4 seconds a couple of months ago, so depending on the version you use it still might be 4 seconds).
This means if they consume the entire 3 or 4 seconds of the main thread time, we only have 1 seconds to process the exception, otherwise it'll result in an ANR like you've faced. In addition, you have your own GlobalExceptionHandler
, which I assume also adds up to the main thread blocking time, so we have even less time to process the exception. From our side we're just holding the lock for a short amount of time until the exception event gets serialized to disk (to make sure we don't lose it) and after that we release the lock. I hope this all makes sense to you.
I don't think we can actually solve this from our side, but we can make some improvements to our crash pipeline that might reduce the chance of getting an ANR for such cases. Also, I'm gonna document this as this keeps popping up when people comparing our SDK against Crashlytics and running them both together.
Thanks for the response! It does make sense. For now, I'll attempt to put Sentry first in the chain. What improvements would you be considering?
Thanks for the response! It does make sense. For now, I'll attempt to put Sentry first in the chain. What improvements would you be considering?
From the top of my head we could do at least 2 improvements right away:
FWIW, those both sound like great options. Especially reducing the 15 second to 3-4s.
Let's also extend our docs with some troubleshooting guidance around the topic of using multiple crash handlers. Regarding prioritize crash events:
@kylannjohnson I've filed #2732 #2733 and https://github.com/getsentry/sentry-docs/issues/7017 to address this, gonna close this issue please track it in the other ones. Thank you!
Integration
sentry-android
Build System
Gradle
AGP Version
7.4.2
Proguard
Enabled
Version
6.16.0
Steps to Reproduce
Not entirely sure. The ANR seems to come from an uncaught exception in coroutine based code.
Expected Result
App shouldn't crash.
Actual Result
here is the ANR with some redactions