mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-05 19:08:23 +00:00
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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user