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

StrictMode DiskReadViolation

Open prashanOS opened this issue 3 years 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

Thanks for the recommendation @prashanOS. Appreciate it. Will definitely have it under radar for upcoming changes 👍

Ayyanchira avatar Nov 23 '22 21:11 Ayyanchira

It relates to https://github.com/Iterable/iterable-android-sdk/issues/631

baole avatar Nov 15 '23 09:11 baole

Any update on this issue?

sgong-pdftron avatar Mar 04 '24 20:03 sgong-pdftron