You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In summary, if an image attempt is made using CachedNetworkImageProvider.resolve, but its not present (a standard 404 webpage is presented instead of an image) then an image error/exception occurs and can be handled. In my case, Im using a FutureBuilder and when this happens I return a status code and the FutureBuilder can present my own error widget. This will happen every time the same image request is made (say if a widget with the missing image is reopened).
HOWEVER,
If the same CachedNetworkImageProvider is now supplied with maxWidth (or maxHeight), then only the first time the image request is made using CachedNetworkImageProvider.resolve then do we get the catchable exception.
If now the widget is closed and re-opened to make the same exact CachedNetworkImageProvider.resolve on the same image, then nothing happens. No errors, nothing. This leaves the FutureBuilder in a forever state of ConnectionStatus.waiting.
I THINK the problem is that the image stream never closes when the exception happens, which leads to a potential memory leak as well as not allowing us to get a new stream? Im not sure if that makes total sense, but I can't understand this otherwise.
🐛 Bug Report
This is cross posted from cache_manager since im not sure if the actual problem is here or there. Baseflow/flutter_cache_manager#439
In summary, if an image attempt is made using
CachedNetworkImageProvider
.resolve
, but its not present (a standard 404 webpage is presented instead of an image) then an image error/exception occurs and can be handled. In my case, Im using aFutureBuilder
and when this happens I return a status code and the FutureBuilder can present my own error widget. This will happen every time the same image request is made (say if a widget with the missing image is reopened).HOWEVER,
If the same
CachedNetworkImageProvider
is now supplied withmaxWidth
(ormaxHeight
), then only the first time the image request is made usingCachedNetworkImageProvider
.resolve
then do we get the catchable exception.If now the widget is closed and re-opened to make the same exact
CachedNetworkImageProvider
.resolve
on the same image, then nothing happens. No errors, nothing. This leaves theFutureBuilder
in a forever state ofConnectionStatus.waiting
.I THINK the problem is that the image stream never closes when the exception happens, which leads to a potential memory leak as well as not allowing us to get a new stream? Im not sure if that makes total sense, but I can't understand this otherwise.
Ive tracked the problem to around here, at least in regards to where the exception is thrown https://github.com/Baseflow/flutter_cached_network_image/blob/develop/cached_network_image/lib/src/image_provider/_image_loader.dart#L129C12-L129C47
The text was updated successfully, but these errors were encountered: