thunderbird / thunderbird/thunderbird-android

StrictMode: Preferences Storage SQLite StrictModeDiskReadViolation

Open
#860 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Kotlin
Stars
14k
Forks
2.8k
Avg merge
3d 3h
Merged PRs (30d)
57

Description

It seems that DiskIO should be done on another Thread.

In case this was not a known-and-ignored warning, here the Stacktrace:

10-23 19:20:02.287 30354 30354 D StrictMode: StrictMode policy violation; ~duration=71 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=31 violation=2
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1137)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1043)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnection.executeForLong(SQLiteConnection.java:597)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnection.setPageSize(SQLiteConnection.java:251)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:213)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:193)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1179)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1168)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:268)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.preferences.Storage.openDB(Storage.java:44)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.preferences.Storage.loadValues(Storage.java:177)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.preferences.Storage.<init>(Storage.java:200)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.preferences.Storage.getStorage(Storage.java:155)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.Preferences.<init>(Preferences.java:44)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.Preferences.getPreferences(Preferences.java:31)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.fsck.k9.K9.onCreate(K9.java:583)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ActivityThread.access$1600(ActivityThread.java:154)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.os.Handler.dispatchMessage(Handler.java:102)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.os.Looper.loop(Looper.java:135)
10-23 19:20:02.287 30354 30354 D StrictMode:    at android.app.ActivityThread.main(ActivityThread.java:5294)
10-23 19:20:02.287 30354 30354 D StrictMode:    at java.lang.reflect.Method.invoke(Native Method)
10-23 19:20:02.287 30354 30354 D StrictMode:    at java.lang.reflect.Method.invoke(Method.java:372)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
10-23 19:20:02.287 30354 30354 D StrictMode:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Storage.java, especially openDB(), loadValues(), and initialization, then trace how Preferences.java and K9.onCreate() access storage. Verify the reported StrictModeDiskReadViolation and determine how the preferences database access should avoid the application main thread, with tests or startup behavior showing that the warning is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java, sqlite
Domain
databases, mobile, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.