From f6dbcfaf05cb109855d4649d655859c9597adec9 Mon Sep 17 00:00:00 2001 From: Colin White Date: Tue, 19 Nov 2024 11:49:38 -0800 Subject: [PATCH] Execute on the main dispatcher if the request has a ViewSizeResolver. --- .../src/androidMain/kotlin/coil3/RealImageLoader.android.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coil-core/src/androidMain/kotlin/coil3/RealImageLoader.android.kt b/coil-core/src/androidMain/kotlin/coil3/RealImageLoader.android.kt index 56e617f30c..d0fdfe0ff9 100644 --- a/coil-core/src/androidMain/kotlin/coil3/RealImageLoader.android.kt +++ b/coil-core/src/androidMain/kotlin/coil3/RealImageLoader.android.kt @@ -20,6 +20,7 @@ import coil3.request.OneShotDisposable import coil3.request.lifecycle import coil3.request.requestManager import coil3.request.transitionFactory +import coil3.size.ViewSizeResolver import coil3.target.Target import coil3.target.ViewTarget import coil3.transition.NoneTransition @@ -31,7 +32,9 @@ internal actual fun needsExecuteOnMainDispatcher( request: ImageRequest, ): Boolean { // Don't dispatch to the main thread unless we have to interact with a view or a lifecycle. - return request.target is ViewTarget<*> || request.lifecycle != null + return request.target is ViewTarget<*> || + request.sizeResolver is ViewSizeResolver<*> || + request.lifecycle != null } internal actual fun getDisposable(