-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
Description
Describe the bug
Android Client SDK seems to run migrations on the main thread, resulting in StrictMode violations from Disk Access.
To reproduce
Set up StrictMode in your app.
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build()
)
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.build()
)
}
Initialize LaunchDarkly SDK via init with timeout set to zero.
LDClient.init(application, ldConfig, ldContext, 0)
Get logs saying there was a violation of StrictMode when running migrations.
Expected behavior
Access to disk happen in a background thread by default. No disk access violation happens as a result of using the LD SDK.
Logs
StrictMode policy violation; ~duration=257 ms: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1596)
at android.app.SharedPreferencesImpl.awaitLoadedLocked(SharedPreferencesImpl.java:275)
at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:301)
at com.launchdarkly.sdk.android.SharedPreferencesPersistentDataStore.getValue(SharedPreferencesPersistentDataStore.java:33)
at com.launchdarkly.sdk.android.Migration.migrateWhenNeeded(Migration.java:35)
at com.launchdarkly.sdk.android.LDClient.init(LDClient.java:134)
at com.launchdarkly.sdk.android.LDClient.init(LDClient.java:238)
SDK version
Android Client 5.6.1
Language version, developer tools
Kotlin 2.1.0 / Android Studio /
OS/platform
Android level 30 to 35
Additional context
veyndan