The Wayback Machine - https://web.archive.org/web/20201029072224/https://github.com/square/leakcanary/issues/1981
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

StrictMode getSharedPreferences failure on API 27 #1981

Open
pyricau opened this issue Oct 17, 2020 · 1 comment
Open

StrictMode getSharedPreferences failure on API 27 #1981

pyricau opened this issue Oct 17, 2020 · 1 comment

Comments

@pyricau
Copy link
Member

@pyricau pyricau commented Oct 17, 2020

Steps to Reproduce

Just start the app on an API 27 device

Updating the config triggers a check for whether heap dumping is enabled in the UI, which in turns triggers a shared preferences load which apparently triggers a strict mode failure. This is likely a stupid AOSP bug (SharedPref loading used to be fully async when loading and block if necessary of first getter call)

D/LeakCanary: LeakCanary is running and ready to detect memory leaks.
D/StrictMode: StrictMode policy violation; ~duration=7 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=327743 violation=2
        at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1440)
        at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
        at java.io.File.exists(File.java:807)
        at android.app.ContextImpl.getDataDir(ContextImpl.java:2197)
        at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:517)
        at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:714)
        at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:368)
        at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
        at leakcanary.internal.activity.screen.AboutScreenKt.getDumpEnabledInAboutScreen(AboutScreen.kt:63)
        at leakcanary.internal.HeapDumpControl.iCanHasHeap(HeapDumpControl.kt:58)
        at leakcanary.internal.InternalLeakCanary$invoke$2.run(InternalLeakCanary.kt:140)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.leakcanary, PID: 29107
    android.os.StrictMode$StrictModeViolation: policy=327743 violation=2
        at android.os.StrictMode.executeDeathPenalty(StrictMode.java:1686)
        at android.os.StrictMode.-wrap3(Unknown Source:0)
        at android.os.StrictMode$AndroidBlockGuardPolicy.handleViolation(StrictMode.java:1679)
        at android.os.StrictMode$AndroidBlockGuardPolicy$1.run(StrictMode.java:1557)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
@pyricau
Copy link
Member Author

@pyricau pyricau commented Oct 17, 2020

Need to gather more context on why strict mode is failing on this, then figure out possible fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.