Open baole opened 1 year ago
@Ayyanchira https://github.com/Iterable/iterable-android-sdk/pull/635 doesn't fix the issue. The fact is that Iterable SDK uses I/O (read files) when calling IterableApi.initialize()
. The below stacktrack is reported by the system when enables StrictMode.
Is it safe to call IterableApi.initialize()
in a background thread/coroutine?
StrictMode policy violation; ~duration=93 ms: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1666)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8071)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:313)
at java.io.File.exists(File.java:813)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:790)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:781)
at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:737)
at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:962)
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:583)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:221)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readKeysetFromPrefs(AndroidKeysetManager.java:250)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:287)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
at com.iterable.iterableapi.IterableKeychain.<init>(IterableKeychain.kt:38)
at com.iterable.iterableapi.IterableApi.getKeychain(IterableApi.java:142)
at com.iterable.iterableapi.IterableApi.retrieveEmailAndUserId(IterableApi.java:364)
at com.iterable.iterableapi.IterableApi.initialize(IterableApi.java:516)
at net.tandem.core_new.analytics.IterableHelperImpl.init(IterableHelperImpl.kt:120)
at net.tandem.TandemApp.onCreate(TandemApp.kt:161)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7015)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2241)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8194)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
@baole were you able to resolve this issue? If so, is it possible if you could share how you did it? Thank you!
Hey, we're facing the same issue. I could workaround it easily by moving the IterableApi.initialize()
call to a background thread, but could anyone please confirm that it's safe to do so? Thanks!
I have several ANR reports on Play store console which are caused by Iterable SDK
[samsung j2corelte (Galaxy J2 Core)]/[Android 8.1 (SDK 27)]
[samsung a51 (Galaxy A51)][Android 13 (SDK 33)]
[Infinix Infinix-X689B (Infinix HOT 10S)][Android 11 (SDK 30)]
Iterable SDK v3.4.15. It happens on almost any device/any Android version. It's on production app and I couldn't reproduce reliably in my dev environment.
Any tips on how to fix? Can I move
IterableApi.initialize
to a background thread?