android-components icon indicating copy to clipboard operation
android-components copied to clipboard

StrictMode violation in SendCrashTelemetryService

Open sraturi opened this issue 6 years ago • 2 comments

Recently, Fenix made the StrictMode penalties more aggressive on startup(Shows pop up dialogs). One of the violations is from SendCrashTelemetryService. The penalty dialog only appears when a crash happens on a startup otherwise just displays a violation log

2020-06-16 12:15:57.367 13107-13107/org.mozilla.fenix.debug D/StrictMode: StrictMode policy violation; ~duration=53 ms: android.os.strictmode.DiskReadViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
        at libcore.io.BlockGuardOs.access(BlockGuardOs.java:69)
        at libcore.io.ForwardingOs.access(ForwardingOs.java:73)
        at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7679)
        at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:281)
        at java.io.File.exists(File.java:815)
        at android.app.ContextImpl.getDataDir(ContextImpl.java:2496)
        at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:619)
        at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:830)
        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:458)
        at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:184)
        at mozilla.components.support.base.ids.SharedIds.preferences(SharedIds.kt:89)
        at mozilla.components.support.base.ids.SharedIds.getIdForTag(SharedIds.kt:32)
        at mozilla.components.support.base.ids.SharedIdsHelper.getIdForTag(SharedIdsHelper.kt:30)
        at mozilla.components.lib.crash.service.SendCrashTelemetryService.onStartCommand(SendCrashTelemetryService.kt:39)
        at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4288)
        at android.app.ActivityThread.access$1900(ActivityThread.java:268)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2014)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7811)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1076)

Possible solution: using StrictMode.resetAfter to allow disk read? or possibly using IO coroutine?

┆Issue is synchronized with this Jira Task

sraturi avatar Jun 16 '20 20:06 sraturi

The core issue here seems to be the SharedIds code. Since that already reads from shared preferences lazily, we should probably just add a resetAfter call.

NotWoods avatar Jun 18 '20 16:06 NotWoods

Not seeing these anymore. Closing.

csadilek avatar Sep 29 '22 22:09 csadilek