This is such a must have for React native, probably should be just part of core.
However I鈥檝e observed that sometimes images don鈥檛 work in my app just to then be fine after restarting it. It鈥檚 super hard to debug, because I can鈥檛 reproduce it. Seems to be happening quite randomly.
Maybe someone else has already encountered this or some idea how to try refetching an Image if it fails. I鈥檒l keep trying ideas but debugging cycles are weeks because I can just try something and then see wether the issue still appears in the following weeks as I use my own app.
I had tried before to implement retrying by passing a number to fast image that I store in state of a Wrapper and then increment on error. This doesn鈥檛 have seemed to fix the error. Maybe it doesn鈥檛 trigger a rerender, maybe the native underlying don鈥檛 refetch on rerender. A little hard to tell without in depth knowledge about the inner workings. Ideally the library could retry fetching internally.
I think there's a ways to go before it could be merged into core (https://github.com/DylanVann/react-native-fast-image/issues/12). I do think that would be nice though. Glad you've found it useful.
Yeah this is tricky, if there's no way to reproduce this issue. There is an issue open for better error handling. Maybe the least we could do is stringify whatever SDWebImage or Glide fails with as one field of the onError callback. You could log that and it might help. (https://github.com/DylanVann/react-native-fast-image/issues/200)
yeah better error reporting would certainly help. Do you know wether rerendering a component will actually refetch an image, I haven't read the sourcecode yet, but one think that could be part of the issue is that once an image has failed rerendering will just resolve the failure from cache until the app is restarted, at least I don't have the feeling that rerendering actually retries fetching images.
It will retry if it fails and calls setSource is run again. It uses the SDWebImageRetryFailed option for SDWebImage, assuming we're talking about iOS, are we?
Getting setSource to run again would be slightly tricky. If the component is unmounted and mounted again that would do it.
I鈥檝e observed the behavior on both iOS and android. I guess I could force unmounte the image, by just rendering null in between retries.
Sent with GitHawk
Does the image exist on the server when you're trying to display it? Is it a timing issue?
yeah it seems completely random, sometimes images just fail but upon restarting the app they are there and they could fail again later. Could have something todo with our server, but nothing obvious, it's really hard to say.
I've never seen that. I'll try to add that error logging tonight so you can see what's going on.
thanks, and I asked my colleague to look into wether it could be a server side issue.
@DylanVann how is it going with that error logging, did you get to it? Couldn鈥檛 find any info yet and wanted to set this up.
same issue here. for us, it seems happened when the network is bad, after i changed the network锛坙et me say wifi -> 4g锛夛紝 the failed image wont reload.
Android seem to reload images that fail to load a first time.
Concerning iOS, the image never reloads if it fail unless the component is refresh
It will be much appreciate to have this support. Seem to be a very basic image function
Most helpful comment
@DylanVann how is it going with that error logging, did you get to it? Couldn鈥檛 find any info yet and wanted to set this up.