Skip to content

[Bug]: DiskReadViolation on initWithContext #2310

Description

@bartek977

What happened?

After adding OneSignal to my app, I can see in logs a lot of DiskReadViolations.

Steps to reproduce?

1. Add implementation("com.onesignal:OneSignal:5.1.34") to the app module
2. Add strict mode logging:

StrictMode.setThreadPolicy(
                StrictMode.ThreadPolicy.Builder()
                    .detectDiskReads()
                    .detectDiskWrites()
                    .detectNetwork()
                    .penaltyLog()
                    .penaltyDialog()
                    .build()
            )
            StrictMode.setVmPolicy(
                StrictMode.VmPolicy.Builder()
                    .detectLeakedSqlLiteObjects()
                    .detectLeakedClosableObjects()
                    .penaltyLog()
                    .build()
            )

3. Invoke initWithContext(this, "APP_ID") in onCreate Application (but after setting strict mode policy logging)
4. Open the app and see logcat.

What did you expect to happen?

no strict mode policy violations

OneSignal Android SDK version

5.1.34

Android version

14

Specific Android models

Samsung Galaxy Tab A8

Relevant log output

StrictMode policy violation; ~duration=327 ms: android.os.strictmode.DiskReadViolation (Ask Gemini)
                                                                                                    	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:8610)
                                                                                                    	at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:332)
                                                                                                    	at java.io.File.exists(File.java:829)
                                                                                                    	at com.onesignal.core.internal.preferences.PreferenceStoreFix.ensureNoObfuscatedPrefStore(PreferenceStoreFix.kt:31)
                                                                                                    	at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:198)
                                                                                                    	at com.onesignal.OneSignal.initWithContext(OneSignal.kt:135)
                                                                                                    	at com.bartekturkosz.myapplication.MyApp.onCreate(MyApp.kt:36)
                                                                                                    	at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1266)
                                                                                                    	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7614)
                                                                                                    	at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2400)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                    	at android.os.Looper.loop(Looper.java:313)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8757)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions