Automattic / Automattic/simplenote-android

Application not responding (ANR) when creating the app

Open
#1,535 0 comments 0 reactions 0 assignees View on GitHub
[Type] Bug crash
Dominant language
Java
Stars
1.9k
Forks
318
Avg merge
15h 23m
Merged PRs (30d)
5

Description

We are getting ANR reports when the app is being created. The reports point to the callback `Simplenote.onCreate(...)` and specifically to `Simplenote.getAccountInfo()`. This is due to database queries done in the main thread.

A possible fix would be to make these calls in a different thread than the main thread:

```java
class Simplenote {

void onCreate(...) {
...
AppLog.add(Type.DEVICE, getDeviceInfo());
AppLog.add(Type.ACCOUNT, getAccountInfo());
AppLog.add(Type.LAYOUT, DisplayUtils.getDisplaySizeAndOrientation(Simplenote.this));
}
```

### Expected
The app starts without ANR problems.

### Observed
The app crashes after 5 seconds.

### Reproduced

**Note: ** to reproduce this issue, we have to have slow queries. This is hard to do but has been observed in Sentry reports.

1. Be sure the app is not running in the background
2. Open the app

Device Make: Nokia
Device Model: Nokia 7 plus
Android Version: 10.0.0
Simplenote Version: 2.23.0

Contributor guide

Open the contributing guide

Research direction

Start by locating Simplenote.onCreate(...) and the getAccountInfo() implementation, then inspect the database queries reached during app creation. Reproduce with slow queries if possible and verify that startup no longer performs those calls on the main thread and completes without an ANR.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.