tinode / ios

Tinodios: Tinode Messaging Client for iOS
Apache License 2.0
243 stars 107 forks source link

<fix> blurred avatar while in personalsetting scene #184

Closed yuyii closed 2 years ago

yuyii commented 2 years ago

I found my avatar is blurred if I use custom image for my avatar. And I found the problem is in RoundImageView.swift.

The image would be overrided by base64 data while icon set. I just added the function param: isAvatar . And it can differ from list icon and avatar.

It's useful for me.

or-else commented 2 years ago

Good catch, thanks. But the fix seems excessive. The RoundImageView is used to display avatars only and nothing but avatars. You don't need to add isAvatar: Bool = false to RoundImageView.set(). It's safe to assume that isAvatar is always true.

or-else commented 2 years ago

The logic here is that the thumbnail is assigned first and displayed until the full image is downloaded. But it looks like in your case Kingfisher downloads the image before direct assignment of a thumbnail. It's a data race.

I.e. this line executes first https://github.com/tinode/ios/blob/8c100634f8bdc347b0dc92cc4aa796517041de0d/Tinodios/widgets/RoundImageView.swift#L111 Then this is executed https://github.com/tinode/ios/blob/8c100634f8bdc347b0dc92cc4aa796517041de0d/Tinodios/widgets/RoundImageView.swift#L125

when it should be the other way.

or-else commented 2 years ago

How about this instead?

https://github.com/tinode/ios/pull/185

yuyii commented 2 years ago

I see. That's good.