Skip to content

Commit 5f832ec

Browse files
authored
Merge pull request #19740 from wordpress-mobile/fix/17154-glide-preload-crash
Catches `ExecutionException` thrown during thumbnail preload
2 parents 5c995ba + b036454 commit 5f832ec

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

WordPress/src/main/java/org/wordpress/android/util/image/ImageManager.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import org.wordpress.android.util.AppLog
4646
import org.wordpress.android.util.image.ImageType.VIDEO
4747
import java.io.File
4848
import java.util.Locale
49+
import java.util.concurrent.ExecutionException
4950
import javax.inject.Inject
5051
import javax.inject.Singleton
5152

@@ -308,11 +309,16 @@ class ImageManager @Inject constructor(
308309
*/
309310
fun preload(context: Context, design: MShot) {
310311
if (!context.isAvailable()) return
311-
GlideApp.with(context)
312-
.downloadOnly()
313-
.load(design)
314-
.submit()
315-
.get() // This makes each call blocking, so subsequent calls can be cancelled if needed.
312+
try {
313+
GlideApp.with(context)
314+
.downloadOnly()
315+
.load(design)
316+
.submit()
317+
.get() // This makes each call blocking, so subsequent calls can be cancelled if needed.
318+
} catch (e: ExecutionException) {
319+
// This is a best effort preload, so we don't want to crash the app if an `ExecutionException` is thrown.
320+
AppLog.e(AppLog.T.UTILS, "Error preloading MShot: $e")
321+
}
316322
}
317323

318324
/**

0 commit comments

Comments
 (0)