urbanairship / android-samples

DEPRECATED - Use https://github.com/urbanairship/android-library instead
Other
33 stars 39 forks source link

Disk reads in main thread makes host application slow. #10

Closed ValleZ closed 10 years ago

ValleZ commented 10 years ago

Check these insane delays: Any UA operation in main thread must not take more than 16 ms. At most, of course.

StrictMode policy violation; ~duration=227 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1123) at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1041) at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:842) at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836) at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62) at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:144) at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133) at android.content.ContentResolver.query(ContentResolver.java:433) at android.content.ContentResolver.query(ContentResolver.java:357) at com.urbanairship.UrbanAirshipResolver.query(Unknown Source) at com.urbanairship.PreferencesResolver.get(Unknown Source) at com.urbanairship.Preferences.getPreferenceFromDatabase(Unknown Source) at com.urbanairship.Preferences.getPreference(Unknown Source) at com.urbanairship.Preferences.getBoolean(Unknown Source) at com.urbanairship.push.PushPreferences.isSoundEnabled(Unknown Source)

jtowle commented 10 years ago

Where is this read happening? Preference reads are cached, but the first one is going to take some time.

jeff

ValleZ commented 10 years ago

Yes, it happens one on application start. Every time application starts. It is not best idea ever to use DB read in MT, even once.

ValleZ commented 10 years ago

It also writes to the database in main thread. At least thanks for not doing network requests in main thread...

jtowle commented 10 years ago

Thanks. The next release of the SDK will includes improvements to this.

It's best to send these kind of bug reports to support@urbanairship.com, as our support team can collect the relevant information (SDK version, logs, etc) and help with prioritization.