customerio / customerio/customerio-android
DiskReadViolation
- Dominant language
- Kotlin
- Stars
- 18
- Forks
- 12
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
**SDK version: **3.10.0**
**Environment: Development & Production
**Are logs available?**
```
StrictMode policy violation; ~duration=10 ms: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1661)
at libcore.io.BlockGuardOs.fstat(BlockGuardOs.java:194)
at libcore.io.ForwardingOs.fstat(ForwardingOs.java:261)
at libcore.io.IoBridge.open(IoBridge.java:563)
at java.io.FileOutputStream.(FileOutputStream.java:236)
at java.io.FileOutputStream.(FileOutputStream.java:186)
at kotlin.io.e.d(FileReadWrite.kt:20)
at io.customer.sdk.data.store.h.c(FileStorage.kt:41)
at io.customer.sdk.queue.QueueStorageImpl.a(QueueStorage.kt:95)
at io.customer.sdk.queue.QueueImpl.i(Queue.kt:68)
at io.customer.sdk.queue.QueueImpl.c(Queue.kt:39)
at pf.h.b(TrackRepository.kt:66)
at ef.c.c(PushMessageProcessorImpl.kt:50)
at io.customer.messagingpush.CustomerIOCloudMessagingReceiver.onReceive(CustomerIOCloudMessagingReceiver.kt:37)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:4663)
at android.app.ActivityThread.-$$Nest$mhandleReceiver(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2357)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.app.ActivityThread.main(ActivityThread.java:8501)
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:878)
```
**Describe the bug**
With StrictMode enabled, when sending a push notification, we can see DiskReadViolation. It's coming from your class `CustomerIOCloudMessagingReceiver`
**To Reproduce**
- Enable [StrictMode](https://developer.android.com/reference/android/os/StrictMode)
```
StrictMode.setThreadPolicy(
StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectAll()
.penaltyLog()
.build()
```
- Send a push notification on a sample following your [documentation implementation ](https://customer.io/docs/sdk/android/push/)
- Look at StrictMode logs
**Expected behavior**
There should not be any DiskReadViolation on main thread.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with CustomerIOCloudMessagingReceiver.kt and follow the stack through TrackRepository.kt, Queue.kt, QueueStorage.kt, and FileStorage.kt. Reproduce the issue with the provided StrictMode policy and push-notification steps, then verify that the receiver path no longer performs disk reads on the main thread and that StrictMode reports no violation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100