Open Leonardo-pixel opened 2 months ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Verified this issue with Visual Studio 17.11.0 Preview 2.1 (8.0.60 & 8.0.40 & 8.0.10). Can repro this issue. IconsTestApp-main.zip
Description
We experienced some weird behavior when using a CollectionView to display items with a couple icons. When scrolling through the CollectionView, we noticed some of the icons where displayed in the wrong place. For example, some icons were shown in locations that shouldn't display an icon at all. We found out that this behavior only occurred on Android, when using a StreamImageSource. We weren't able to reproduce this issue on iOS and Windows, or when using a FileImageSource.
To make sure this wasn't because of our implementation, we managed to reproduce the issue in a simple Maui application, a linkt to this project is added below.
This is how it works: We have a single page consisting of the CollectionView with a DataTemplate containing a couple labels and images:
The GestureRecognizer is to verify whether the tapped item should display a third icon or not. The item that we are displaying is a simple object with a name, description and three file names. These file names are all strings and are used in the custom image control to load the image via a stream.
When the value of the CustomImageSource property is changed a task is queued to update the Source property of the image. This queue is added to make sure the sequence of tasks is always correct (we want to rule out that the issue we're having is due to timing). It is, however, still possible (maybe even easier) to reproduce this issue when not utilizing the queue. This is how we retrieve the image and update the Source:
The await is used to make it easier to reproduce the issue. When the source is updated fast enough, this becomes much harder. Below is a recording of the issue (notice how the first three items shouldn't have a third icon):
https://github.com/dotnet/maui/assets/51745898/7c0aa22c-196d-4fd7-b03a-e2294a2d2ab3
We're fairly certain this issue is a result of using a StreamImageSource in combination with the recycling mechanism of the CollectionView. I'd also like to point out that this did work when we were still using Xamarin, we did however use the FFImageLoading library so that might have been the reason the issue wasn't present when using Xamarin. Finally, at the time of writing we are using version 8.0.60, but this issue was also present in previous versions (we haven't tested all of them).
Steps to Reproduce
Link to public reproduction project repository
https://github.com/Leonardo-pixel/IconsTestApp
Version with bug
8.0.60 SR6
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
A work-around could be to use a FileImageSource instead, however in our actual application, we download the icons we want to display and having to convert these to a FileImageSource would result in a (probably big) performance hit.
Relevant log output
No response