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

DiskRead and DiskWrite Violations in ChuckerCollector #737

Closed
Alireza-Farahani opened this issue Dec 8, 2021 · 2 comments · Fixed by #750
Closed

DiskRead and DiskWrite Violations in ChuckerCollector #737

Alireza-Farahani opened this issue Dec 8, 2021 · 2 comments · Fixed by #750
Assignees
Labels
bug Something isn't working

Comments

@Alireza-Farahani
Copy link

✍️ Describe the bug

I'm not even sure its Chucker problem or not, but Creating ChuckerInterceptor instance (done by Hilt in out app) results in both DiskReadViolation and DiskWriteViolation.

android.os.strictmode.DiskReadViolation: null
    at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
    at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
    at java.io.File.exists(File.java:815)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:653)
    at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:644)
    at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:600)
    at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:809)
    at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:437)
    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:179)
    at com.chuckerteam.chucker.api.RetentionManager.<init>(RetentionManager.kt:29)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:28)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:23)
    at com.chuckerteam.chucker.api.ChuckerInterceptor$Builder.build(ChuckerInterceptor.kt:366)
--------------------------
android.os.strictmode.DiskWriteViolation: null
    at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1460)
    at java.io.UnixFileSystem.delete(UnixFileSystem.java:294)
    at java.io.File.delete(File.java:1037)
    at com.chuckerteam.chucker.internal.data.room.ChuckerDatabase$Companion.create(ChuckerDatabase.kt:22)
    at com.chuckerteam.chucker.internal.data.repository.RepositoryProvider.initialize(RepositoryProvider.kt:34)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:32)
    at com.chuckerteam.chucker.api.ChuckerCollector.<init>(ChuckerCollector.kt:23)
    at com.chuckerteam.chucker.api.ChuckerInterceptor$Builder.build(ChuckerInterceptor.kt:366)

💣 Steps to reproduce

StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
    .detectDiskReads()
    .detectDiskWrites()
    .penalty<whatever>
    .build()
)

🔧 Expected behavior

Getting no violation

📷 Screenshots

📱 Tech info

  • Device: Pixel 2
  • OS: Android 11
  • Chucker version: 3.5.2

📄 Additional context

Actually I traced those two violations and one is a simple File delete and the other a new SharedPref and I know it's not much an issue, performance wise.

@vbuberen
Copy link
Collaborator

Thanks for the report. I will try to reproduce this week and get to you.

Seems like we need to enable every single check in StrictMode to cover all use cases our users might have 🙂

@vbuberen vbuberen added the bug Something isn't working label Dec 16, 2021
@vbuberen
Copy link
Collaborator

Ok, I was able to reproduce and will work on fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants