SDWebImageSwiftUI icon indicating copy to clipboard operation
SDWebImageSwiftUI copied to clipboard

cache key collision

Open 4leyam opened this issue 5 years ago • 3 comments

hello here, i've been trying something using this library, and encountered a weird behaviour, the following is a simpler version of the code i wrote.

    VStack {

          //... some code here

            WebImage(url: URL(string: url)
                    ).placeholder {
                        Rectangle().fill(Color(UIColor.systemGray6))
                            .frame(width: self.postWidth , height: self.postHeight)
                            .aspectRatio(contentMode: .fill)
                            .overlay(Text("Loading..."))
                    }.resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(width: self.postWidth , height: self.postHeight)
                        .clipped()
                        .cornerRadius(4)

         //... some code here too

}.background(
            
            WebImage(url: URL(string: url)
                , context: [.imageThumbnailPixelSize : CGSize(width: self.postWidth / 8 , height: self.postHeight / 8) ,]
            ).resizable()
                .aspectRatio(contentMode: .fill)
                .frame(width: self.postWidth , height: self.postHeight)
                .clipped()
                .blur(radius: 40)
            
        )
            .clipped()

my problem is that sometimes i get the low quality background image on top too. It seems like it's fetching the background low image for the top view too. maybe they are using the same cache key? or maybe i'm just writing rubbish... anyway can you please advice any solution for this problem? thank you in advance.

4leyam avatar Jul 08 '20 15:07 4leyam

The thumbnail decoding feature (via .imageThumbnailPixelSize) will have different cache key even they share the same URL.

Sounds like a bug. Let me have a try to reproduce this issue.

dreampiggy avatar Jul 09 '20 09:07 dreampiggy

yeah that's what is said in the documentation, but still i'm having that weird behaviour sometimes

4leyam avatar Jul 09 '20 09:07 4leyam

Any update here?

4leyam avatar Jul 23 '20 17:07 4leyam