dmytro-anokhin / url-image

AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.
MIT License
1.1k stars 96 forks source link

Caching images causes URLImage to reload images without view update in keyboard extension #161

Open amirshane opened 2 years ago

amirshane commented 2 years ago

Summary and/or background The app uses URLImage to load images into a keyboard extension based on user search queries. The images are cached. If the user types or taps on text fields the images loaded will reload and reanimate. Additionally, the images will still reload on a new search query even if their new search query does not result in updated images returned. Removing the caching removes the bug but there is no longer caching which is very desired.

OS and what device you are using

Version of URLImage library Version 3.1.0

What you expected would happen I expected for the images to not be reloaded when the search results are not updated and that tapping in text fields would not cause the images to reload.

What actually happens The images reload even if the search results are not updated and tapping in text fields or typing in them causes the images to reload.

Sample code I am adding the following URLImageService to the view environment for caching. If I remove this then the bug will disappear (but so will the caching).

let urlImageService = URLImageService(fileStore: URLImageFileStore(),
                                                  inMemoryStore: URLImageInMemoryStore())
myView
    .environment(\.urlImageService, urlImageService)

Test data The issue occurs with any image URLs.

Additional information

Misc

dmytro-anokhin commented 2 years ago

Hello, thank you for detailed report. I'm currently busy with regular work, but I will investigate it when I get some free time.

lokizero00 commented 2 years ago

Hello, i got the same issue when update views.

dmytro-anokhin commented 2 years ago

Hi, unfortunately I'm no longer actively working on the package. But if it happens and you find a fix - I will gladly review PR.