From 99618d61bf12b4b8b0aa8ce680547ca534c56dc8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 16 Jun 2026 17:56:21 +0000 Subject: [PATCH] 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. --- app/src/main/java/com/greenart7c3/nostrsigner/Amber.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/Amber.kt b/app/src/main/java/com/greenart7c3/nostrsigner/Amber.kt index 3f9c0e2c..533a4fa1 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/Amber.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/Amber.kt @@ -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() {