diff --git a/app/src/main/java/net/jeena/jtubetv/JTubeApp.kt b/app/src/main/java/net/jeena/jtubetv/JTubeApp.kt index fe13971..a9d3f43 100644 --- a/app/src/main/java/net/jeena/jtubetv/JTubeApp.kt +++ b/app/src/main/java/net/jeena/jtubetv/JTubeApp.kt @@ -1,6 +1,7 @@ package net.jeena.jtubetv import android.app.Application +import kotlinx.coroutines.Dispatchers import coil.ImageLoader import coil.ImageLoaderFactory import net.jeena.jtubetv.data.PeerTubeRepository @@ -33,9 +34,20 @@ class JTubeApp : Application(), coil.ImageLoaderFactory { * TVs are slow compositors: decode thumbnails as RGB_565 at capped size so * scrolling rows keep a smooth frame rate (user: "the animation has very low fps"). */ - override fun newImageLoader(): ImageLoader = - ImageLoader.Builder(this) + override fun newImageLoader(): ImageLoader { + // A sched trace on the TV (release build) showed the main thread being + // descheduled hundreds of times during navigation while the render + // pipeline (Mali/RenderThread/SF/Dolby) saturated all 4 cores together + // with Coil's image work — a burst of parallel 30 ms bitmap decodes + // starved the main thread for over a second (the felt "2fps"). Capping + // Coil's parallel work: images still fill in steadily while scrolling, + // but the decode/fetch pool can no longer eat every core at once. + return ImageLoader.Builder(this) .bitmapConfig(android.graphics.Bitmap.Config.RGB_565) .crossfade(false) + .dispatcher(Dispatchers.IO.limitedParallelism(2)) + .decoderDispatcher(Dispatchers.Default.limitedParallelism(2)) + .transformationDispatcher(Dispatchers.Default.limitedParallelism(1)) .build() + } } \ No newline at end of file