StrictMode DiskReadViolation when loading image File from disk
See original GitHub issueDescribe the bug
I load an image “file://” Uri from disk. Coil obviously loads it on main thread, or at least does an “last modified time” check on main thread. I even tried specifying IO dispatcher with imageView.load(fileUri) { dispatcher(Dispatchers.IO) }
but it doesn’t help.
Expected behavior Expected behaviour is that disk should never be touched from main thread.
To Reproduce
imageView.load(fileUri)
where file Uri is a literal “file://” Uri.
Logs/Screenshots
2020-05-02 22:04:02.901 27160-27160/com.berry4u.app D/StrictMode: StrictMode policy violation; ~duration=5 ms: android.os.strictmode.DiskReadViolation
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
at java.io.UnixFileSystem.getLastModifiedTime(UnixFileSystem.java:289)
at java.io.File.lastModified(File.java:939)
at coil.fetch.FileFetcher.key(FileFetcher.kt:14)
at coil.fetch.FileFetcher.key(FileFetcher.kt:12)
at coil.RealImageLoader$executeInternal$2$deferred$1.invokeSuspend(RealImageLoader.kt:525)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:69)
at kotlinx.coroutines.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:337)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:109)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:158)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:54)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
at coil.RealImageLoader.execute(RealImageLoader.kt:143)
Version 0.10.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
StrictMode - Android Developers
StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and ......
Read more >What is strict mode policy violation in Android - Stack Overflow
(1) It turns out that Strict mode doesn't actually prevent you from making writes to the disk it just gives a warning.
Read more >Smooth Operator: Using StrictMode to make your Android App ...
You can see it points out that its a DiskReadViolation and points to ... "/path/to/image.jpg") GlideApp.with(itemView.context) .load(file) ...
Read more >AdManager SDK for Android throwing StrictMode violation for ...
The AdManager SDK for Android's PublisherAdView is throwing strict mode ... ReadFromDisk Violation - Ad First Load: ... isDirectory(File.java:845)
Read more >core/java/android/os/StrictMode.java - platform/frameworks/base
you may not use this file except in compliance with the License. ... <p>StrictMode is most commonly used to catch accidental disk or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@micHar
Here is an example how to deactivate it: https://github.com/PaulWoitaschek/Voice/commit/03096be8f679ef879074bae6084d3e88e4bea3fe
Coil synchronously fulfills images in the memory cache (to avoid white flashes) so it’s not possible to move the check to a background thread.