iterable-android-sdk icon indicating copy to clipboard operation
iterable-android-sdk copied to clipboard

StrictMode DiskReadViolation

Open prashanOS opened this issue 1 year ago • 3 comments

Looks like the Iterable SDK is reading/writing to disk from the current thread instead of delegating to an IO thread.

Note this is just one example - would recommend doing an audit of the SDK of all locations where you read/write to disk to ensure the exposed methods are main-safe.

java.lang.RuntimeException: StrictMode ThreadPolicy violation
... (removed for brevity)
Caused by: android.os.strictmode.DiskReadViolation
	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1658)
	at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
	at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
	at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7775)
	at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:281)
	at java.io.File.exists(File.java:813)
	at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:759)
	at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:750)
	at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:706)
	at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:931)
	at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:553)
	at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:217)
	at com.iterable.iterableapi.IterableApi.getPreferences(IterableApi.java:1038)
	at com.iterable.iterableapi.IterableApi.retrieveEmailAndUserId(IterableApi.java:1066)
	at com.iterable.iterableapi.IterableApi.initialize(IterableApi.java:295)
	at com.iterable.iterableapi.IterableApi.initialize(IterableApi.java:274)

Would highly recommend setting up StrictMode in your sample apps in CI so that you can catch these issues!

prashanOS avatar Nov 23 '22 21:11 prashanOS