mattprecious/telescope

Initializing TelescopeLayout causes StrictMode violations

Closed this issue · 2 comments

Getting the external cache directory causes strict mode errors for disk access on mainthread. It looks like it might be possible to defer that call until after the constructor, possibly until the SaveScreenshotTask. I can try and submit a PR fixing this up.

07-05 13:31:41.118 8906-8906/com.app.package D/StrictMode: StrictMode policy violation; ~duration=58 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=4784159 violation=2
                                                                                at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1263)
                                                                                at libcore.io.BlockGuardOs.statvfs(BlockGuardOs.java:297)
                                                                                at java.io.File.getTotalSpace(File.java:1126)
                                                                                at android.os.storage.StorageManager.getStorageLowBytes(StorageManager.java:943)
                                                                                at android.os.storage.VolumeInfo.buildStorageVolume(VolumeInfo.java:362)
                                                                                at com.android.server.MountService.getVolumeList(MountService.java:2758)
                                                                                at android.os.storage.IMountService$Stub.onTransact(IMountService.java:1676)
                                                                                at android.os.Binder.execTransact(Binder.java:453)
                                                                            # via Binder call with stack:
                                                                            android.os.StrictMode$LogStackTrace
                                                                                at android.os.StrictMode.readAndHandleBinderCallViolations(StrictMode.java:1911)
                                                                                at android.os.Parcel.readExceptionCode(Parcel.java:1601)
                                                                                at android.os.Parcel.readException(Parcel.java:1570)
                                                                                at android.os.storage.IMountService$Stub$Proxy.getVolumeList(IMountService.java:790)
                                                                                at android.os.storage.StorageManager.getVolumeList(StorageManager.java:883)
                                                                                at android.os.Environment$UserEnvironment.getExternalDirs(Environment.java:83)
                                                                                at android.os.Environment$UserEnvironment.buildExternalStorageAppFilesDirs(Environment.java:127)
                                                                                at android.os.Environment.buildExternalStorageAppFilesDirs(Environment.java:539)
                                                                                at android.app.ContextImpl.getExternalFilesDirs(ContextImpl.java:465)
                                                                                at android.app.ContextImpl.getExternalFilesDir(ContextImpl.java:458)
                                                                                at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:213)
                                                                                at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:213)
                                                                                at com.mattprecious.telescope.TelescopeLayout.getScreenshotFolder(TelescopeLayout.java:392)
                                                                                at com.mattprecious.telescope.TelescopeLayout.<init>(TelescopeLayout.java:138)
                                                                                at com.mattprecious.telescope.TelescopeLayout.<init>(TelescopeLayout.java:80)
                                                                                at com.mattprecious.telescope.TelescopeLayout.<init>(TelescopeLayout.java:76)
                                                                                ...
                                                                                at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1189)
                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2398)
                                                                                at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                at android.app.ActivityThread.access$900(ActivityThread.java:150)
                                                                                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                at android.os.Looper.loop(Looper.java:148)
                                                                                at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                at java.lang.reflect.Method.invoke(Native Method)
                                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:764)
                                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

Are you running the latest? I'm pretty sure I fixed all of these in 2.1.0.

oh. thought we were on the latest. Looks like its fixed in the code. Deleting the issue. Sorry bout that.