From 7ecabef704a64a6b7ba7d54ae1fab24d59ec57a3 Mon Sep 17 00:00:00 2001 From: Peter Velkov Date: Fri, 25 Nov 2022 12:55:43 +0200 Subject: [PATCH] [fix] ImageLoader images are not added to `ImageUriCache` Previously loaded images used to be added to ImageUriCache It seems the logic was accidentally removed here: https://github.com/necolas/react-native-web/commit/f4e8b6b1942aa1ea0a36f596c34e0271abbb0b16#diff-7cb74a3a32d73857be80350ecd1ea131d256bd5af11d2000e4fc2d03c2230584L361 And now the `ImageUriCache` is only updated by preload/getSize --- packages/react-native-web/src/modules/ImageLoader/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-native-web/src/modules/ImageLoader/index.js b/packages/react-native-web/src/modules/ImageLoader/index.js index b1bebce80..03fde0e90 100644 --- a/packages/react-native-web/src/modules/ImageLoader/index.js +++ b/packages/react-native-web/src/modules/ImageLoader/index.js @@ -81,12 +81,13 @@ const ImageLoader = { release(requestId: number) { const request = requests[requestId]; if (request) { - const { image, cleanup } = request; + const { image, cleanup, source } = request; if (cleanup) cleanup(); image.onerror = null; image.onload = null; image.src = ''; + ImageUriCache.remove(source.uri); delete requests[requestId]; } }, @@ -135,7 +136,8 @@ const ImageLoader = { const handleLoad = () => { // avoid blocking the main thread - const onDecode = () => + const onDecode = () => { + ImageUriCache.add(source.uri); onLoad({ source: { uri: image.src, @@ -143,6 +145,7 @@ const ImageLoader = { height: image.naturalHeight } }); + }; // Safari currently throws exceptions when decoding svgs. // We want to catch that error and allow the load handler