Skip to content

Commit

Permalink
[fix] ImageLoader images are not added to ImageUriCache
Browse files Browse the repository at this point in the history
Previously loaded images used to be added to ImageUriCache
It seems the logic was accidentally removed here: f4e8b6b#diff-7cb74a3a32d73857be80350ecd1ea131d256bd5af11d2000e4fc2d03c2230584L361

And now the `ImageUriCache` is only updated by preload/getSize
  • Loading branch information
kidroca committed Dec 1, 2022
1 parent c88663b commit 8324905
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/react-native-web/src/modules/ImageLoader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
},
Expand Down Expand Up @@ -135,14 +136,16 @@ const ImageLoader = {

const handleLoad = () => {
// avoid blocking the main thread
const onDecode = () =>
const onDecode = () => {
ImageUriCache.add(source.uri);
onLoad({
source: {
uri: image.src,
width: image.naturalWidth,
height: image.naturalHeight
}
});
};

// Safari currently throws exceptions when decoding svgs.
// We want to catch that error and allow the load handler
Expand Down

0 comments on commit 8324905

Please sign in to comment.