Database on Main Thread

The main UI thread in a mobile application handles user interface events such as button presses and page scrolls. To prevent App Hangs and Application Not Responding errors, the main UI thread shouldn't be used for performing long-running operations like database queries. These kinds of operations block the whole UI until they finish running and get in the way of the user interacting with the app.

The detector for this performance issue looks at the total non-overlapping duration for database spans on the main thread. If it exceeds 16ms, a Performance Issue is created.

You can configure detector thresholds for database on main thread issues in Project Settings > Performance:

Database on Main Thread detector threshold settings

Span evidence identifies the root cause of the database on main thread problem by showing you three main aspects:

  • Transaction name
  • Parent Span: Where the database spans occurred
  • Offending Span: The actual spans that are performing database queries in the main thread

Database Span Evidence

View it by going to the Issues page in Sentry, selecting your Android project, clicking on the database error you want to examine, then scrolling down to the "Span Evidence" section in the "Details" tab.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").