Limit parallelism for Coil image loading

Reference: https://www.reddit.com/r/androiddev/comments/xbeizp/comment/io4ytdv/

Co-authored-by: ivaniskandar <ivaniskandar@users.noreply.github.com>
(cherry picked from commit eb6ba96b573a43e171c181f83919f8e16f97ce8d)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/App.kt
This commit is contained in:
arkon 2022-11-18 22:57:54 -05:00 committed by Jobobby04
parent 13c0ab1930
commit 44603a3efa

View File

@ -72,6 +72,7 @@ import exh.log.XLogLogcatLogger
import exh.log.xLogD import exh.log.xLogD
import exh.log.xLogE import exh.log.xLogE
import exh.syDebugVersion import exh.syDebugVersion
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
@ -206,6 +207,11 @@ class App : Application(), DefaultLifecycleObserver, ImageLoaderFactory {
crossfade((300 * this@App.animatorDurationScale).toInt()) crossfade((300 * this@App.animatorDurationScale).toInt())
allowRgb565(getSystemService<ActivityManager>()!!.isLowRamDevice) allowRgb565(getSystemService<ActivityManager>()!!.isLowRamDevice)
if (networkPreferences.verboseLogging().get()) logger(DebugLogger()) if (networkPreferences.verboseLogging().get()) logger(DebugLogger())
// Coil spawns a new thread for every image load by default
fetcherDispatcher(Dispatchers.IO.limitedParallelism(8))
decoderDispatcher(Dispatchers.IO.limitedParallelism(2))
transformationDispatcher(Dispatchers.IO.limitedParallelism(2))
}.build() }.build()
} }