Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode DiskReadViolation #480

Open
prashanOS opened this issue Nov 23, 2022 · 3 comments
Open

StrictMode DiskReadViolation #480

prashanOS opened this issue Nov 23, 2022 · 3 comments

Comments

@prashanOS
Copy link

prashanOS commented Nov 23, 2022

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!

@Ayyanchira
Copy link
Member

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

@baole
Copy link

baole commented Nov 15, 2023

It relates to #631

@sgong-pdftron
Copy link

Any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants