From 7211119d2325a67067f9dd7296cdcb9f91624c7f Mon Sep 17 00:00:00 2001 From: Peter Abbondanzo Date: Fri, 1 Nov 2024 15:26:58 -0700 Subject: [PATCH] Add cache control check to multisource (#47357) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47357 `MultiSourceHelper` should not yield an `ImageSource` that has its cache control policy set to `RELOAD`. This change skips such sources when computing the bestCached item (but not best item) Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D65337414 fbshipit-source-id: bdd0d55f4a65128b141a1c7a132dba085232fa11 --- .../com/facebook/react/views/imagehelper/MultiSourceHelper.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.kt index bd2711ed81b..c7619aac19b 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/imagehelper/MultiSourceHelper.kt @@ -8,6 +8,7 @@ package com.facebook.react.views.imagehelper import com.facebook.imagepipeline.core.ImagePipelineFactory +import com.facebook.react.modules.fresco.ImageCacheControl /** Helper class for dealing with multisource images. */ public object MultiSourceHelper { @@ -62,7 +63,10 @@ public object MultiSourceHelper { best = source } if (precision < bestCachePrecision && + source.cacheControl != ImageCacheControl.RELOAD && (imagePipeline.isInBitmapMemoryCache(source.uri) || + // TODO: T206445115 isInDiskCacheSync is a blocking operation, we should move this to + // a separate thread imagePipeline.isInDiskCacheSync(source.uri))) { bestCachePrecision = precision bestCached = source