Describe the bug
We're experiencing ANRs in our app. After debugging with StrictMode enabled, we discovered that Purchases.configure() is performing disk I/O operations on the main thread.
-
Environment
- Platform: Android
- SDK version:
9.12.2
- OS version: minSdk: 28, targetSdk: 35, compileSdk: 35
- Android Studio version:
Android Studio Otter | 2025.2.1
- How widespread is the issue. Percentage of devices affected: Unknown - detected through StrictMode in debug builds, likely affects all devices when
Purchases.configure() is called on the main thread
-
Debug logs that reproduce the issue
StrictMode policy violation; ~duration=170 ms: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1683)
at libcore.io.BlockGuardOs.access(BlockGuardOs.java:74)
at libcore.io.ForwardingOs.access(ForwardingOs.java:128)
at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:8582)
at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:332)
at java.io.File.exists(File.java:829)
at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:819)
at android.app.ContextImpl.ensurePrivateCacheDirExists(ContextImpl.java:815)
at android.app.ContextImpl.getCacheDir(ContextImpl.java:926)
at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:328)
at com.revenuecat.purchases.paywalls.FontLoader.<init>(FontLoader.kt:30)
at com.revenuecat.purchases.PurchasesFactory.createPurchases(PurchasesFactory.kt:325)
at com.revenuecat.purchases.PurchasesFactory.createPurchases$default(PurchasesFactory.kt:68)
at com.revenuecat.purchases.Purchases$Companion.configure(Purchases.kt:1105)
...
- Steps to reproduce, with a description of expected vs. actual behavior
- Enable StrictMode with disk read detection in the Application class
- Call
Purchases.configure() on the main thread
- Observe StrictMode violation and potential ANR
Expected behavior:
Purchases.configure() should not perform disk I/O operations on the main thread.
Actual behavior:
Purchases.configure() performs disk I/O operations on the main thread and can cause ANRs.
- Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Additional context
This issue appears to be related to #1629, which also reports ANRs when calling Purchases.configure() on the main thread.
Describe the bug
We're experiencing ANRs in our app. After debugging with StrictMode enabled, we discovered that
Purchases.configure()is performing disk I/O operations on the main thread.Environment
9.12.2Android Studio Otter | 2025.2.1Purchases.configure()is called on the main threadDebug logs that reproduce the issue
Purchases.configure()on the main threadExpected behavior:
Purchases.configure()should not perform disk I/O operations on the main thread.Actual behavior:
Purchases.configure()performs disk I/O operations on the main thread and can cause ANRs.Additional context
This issue appears to be related to #1629, which also reports ANRs when calling
Purchases.configure()on the main thread.