XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] AvatarView inside ListView using no cache and ListView CachingStrategy=RecycleElement

Open tonyfonager opened this issue 4 years ago • 2 comments

Description

Please note : Only tested in details on iOS!

If you put an AvatarView inside a ListView with cache disabled on the source, it gets very confused.

In my AvatarRepro project (included here), I have added 4 controls per record in the ListView and having the same image source:

  • Image #1 : Caching enabled
  • Image #2 : No cache
  • AvatarView #1 : Caching enabled
  • AvatarView #2 : No cache

So it seems like its related to the way the ListView CachingStrategy is used:

CachingStrategy = RetainElement (default)

  • Image #1 : no issues
  • Image #2 : no issues (loads slowly as cache is disabled)
  • AvatarView #1 : no issues
  • AvatarView #2 : no issues (loads slowly as cache is disabled)

CachingStrategy = RecycleElement

  • Image #1 : no issues
  • Image #2 : no issues (loads slowly as cache is disabled)
  • AvatarView #1 : no issues - AvatarView #2 : lots of issues, sometimes image is loaded - sometimes not, if you scroll up and down you will notice that images previously loaded and not reloaded

Steps to Reproduce

Try running the included AvatarRepro.zip solution and change ListView CachingStrategy inside the AvatarPage.xaml between RecycleElement and RetainElement and look what happens to the last image (AvatarView #2).

Expected Behavior

Even though cache is disabled on the AvatarView source, images with valid sources should always be visible.

Actual Behavior

When caching on an AvatarView image source is disabled and ListView CachingStrategy is RecycleElement, it gets very confused.

Basic Information

  • Version with issue:
  • IDE: Visual Studio for Mac 8.8 (build 2913)
  • Platform Target Frameworks:
    • iOS: 14.2
  • Nuget Packages: 1.0.0-pre5

(use NuGet 1.0.0-preview2421 to avoid "task cancelled" error - its included in the zip file)

AvatarRepro.zip

tonyfonager avatar Nov 19 '20 10:11 tonyfonager

I am still experiencing a similiar issue in my project. @tonyfonager Did you manage to solve this?

F-Goncalves avatar May 20 '22 13:05 F-Goncalves

I think I'm running into this issue also. If I use RetainElement in my ListView, the Images load, but the Text binding only works for the visible items. Anything I have to scroll to just shows as blank unless it has a valid ImageSource.

If however, I have it set to RecycleElement, everything in the list view works, but only once. If I refresh the list or tap an item which goes to another page which also has an AvatarView, any images no longer show and every AvatarView just shows the Text binding from that point on throughout the entire app.

I should also note that it seems to work fine on iOS, the issue is only on Android

gtrafford avatar Jun 03 '22 09:06 gtrafford