Warm up Coil ImageLoader off the main thread

The singleton ImageLoader factory reads cacheDir, so letting the first
AsyncImage build it lazily during composition tripped StrictMode's
DiskReadViolation on the UI thread. Pre-build it on the IO scope at startup.
This commit is contained in:
Claude
2026-06-16 17:56:21 +00:00
parent f02ee8d69f
commit 99618d61bf
@@ -356,6 +356,13 @@ class Amber :
instance = this
stats.createNotificationChannel()
Thread.setDefaultUncaughtExceptionHandler(UnexpectedCrashSaver(crashReportCache, applicationIOScope))
// Build Coil's singleton ImageLoader off the main thread. Its factory
// (newImageLoader) touches cacheDir, so letting the first AsyncImage
// build it lazily during composition trips StrictMode's DiskReadViolation.
applicationIOScope.launch {
SingletonImageLoader.get(this@Amber)
}
}
private fun enableStrictMode() {