Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

CacheNetworkImageProvider hangs/does not proceed when maxWidth/maxHeight are set and the image is not available #901

Open
mark8044 opened this issue Dec 9, 2023 · 0 comments

Comments

@mark8044
Copy link

mark8044 commented Dec 9, 2023

馃悰 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 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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant