-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Cache cell sizes after resize from estimates #12919
Conversation
Thank you @hartez -- I believe this will fix a ton of the CollectionView issues I've been running into and am really looking forward to this PR getting merged in! Reading the description it sounds like it may fix at least these also: #12675 #12622 #12697 #12555 #12722 When do you estimate this PR might be merged so I could try a nightly build? |
Assuming all the tests pass, I'm hoping we can get it reviewed, merged, and into nightly builds next week. |
@Tommigun1980 you can also grab the nuget for this PR from here: |
Failed iOS test is not related |
Hi! I tested the referenced NuGet but unfortunately it hard crashes with the following when its data is populated:
EDIT: It was because I had accidentally left in ViewCell declarations in the data templates (as I was using a ListView earlier). The error message says "Please file a bug" so I'll leave this comment here. Maybe the error message could be more descriptive of what went wrong instead of saying to file a bug, as if you have a lot of XAML it's easy to accidentally leave in some ViewCells in the data templates when converting ListViews to CollectionViews. |
@hartez @rmarinho @jsuarezruiz Ok I completed my testing and unfortunately it didn't fix the main issues I've been having with collection views, and introduced two regressions. Please see the following video:
I am more than willing to offer my help with these issues as I really have to get the collection view working. I currently am using a ListView with a ton of timing based hacks, but the more entries there are in the list the more time I have to add to delays to get it to work, so it is not a permanent fix. I'd urge not to merge this in yet, and as I said I'd be more than willing to spend time on getting this right as I am dependent on this starting to work (testing, repro cases, whatever you need). Thank you. Disclaimer: The photos in the videos are images I picked randomly from the web for my personal testing only, and are not real users. |
@hartez @rmarinho @jsuarezruiz For posterity, here is a video of the same process performed on a collection view without this PR: https://drive.google.com/file/d/12FCvJHwiizfLIVbP7FNRFRyxVxOyUZbl/view?usp=sharing Some notes:
Maybe there is an incorrect calculation in the collection view that assumes that all elements have a uniform height, even when set to measure all items? It truly looks like it in all the testing I've done. I know this is a lot of text but I think it'd be valuable for someone to read through it and check out the time stamps in the videos I posted, as these issues must be tackled at some point. |
I tagged you also @jsuarezruiz as you've been looking into these issues and here's some additional information, so I hope you don't mind! |
@Tommigun1980 I would like you thank you for putting in such an effort to get this working. I've been trying to make a decent chat with XF for many years now, but I've had to fall back to time-based hacks with ListView as you are describing. To the XF team I would like to say that I know such an abstraction as the CollectionView is hard to get right, and I do really appreciate all the work you've put into it but it's still missing a complete sample which would highlight all the issues. Make an example chat with it. Something that mimicks whatsapp, facebook messenger and the like. To everyone involved, keep up the good work! |
@Tommigun1980 How are you adding new items to you CollectionView? Is it just an ObservableCollection that you're appending to? |
Hi @hartez. That is correct, it's just a regular Add: var chatMessageEx = (await this.ModelToModelExService.ToChatMessageEx(new List<ChatMessageDTO>() { args.ChatMessage }, new List<ChatRoomDTO>() { args.ChatRoom }, this.GetCancellationToken())).Single(); // enrich chat message DTO for XAML side
this.ChatMessages.Add(chatMessageEx); // add it to the collection The collection in question is an OptimizedObservableCollection (https://github.com/xamarinhq/xamu-infrastructure/blob/598f97d6f5cc68fc603873e913ccc9089dbc60df/src/XamU.Core/Collections/OptimizedObservableCollection.cs), but the Add() is not overridden. |
Hi. I was wondering what the status is of this atm? I am extremely dependent on the collection view starting to work (or even the list view) for the chat portion of my app, where the collection/list views contain items of different sizes. Did the videos I provided showcase the problems? Is there anything else I can do? Thank you! |
Hi again. I need to know what will happen to the CollectionView so any update would be greatly appreciated. Did the videos make sense or is there some clarification I can do on the issues? |
Just pushed an update to this PR which I think will address the problems you're seeing. Rather than caching template sizes, we're caching individual cell sizes. I created a "chat" test page with randomly sized text messages to reproduce the specific issues you are concerned about, and right now it can add new messages without the weird jumping around and resizing we were seeing before. It's running through the automated tests right now, so I should know Monday if I missed anything major. Assuming all goes well, we've still got a pretty good shot at this making it in the the 5.0 stable release. If we somehow miss that, then it will be in 5.1. |
THANK YOU! Really looking forward to testing it. |
Oh and let me know if there’s a way to test this early so I can run it through my tests also in case you want another test pass at it. |
@Tommigun1980 you can get the nupkg to test this changes from here: bug here you go |
I tested with the linked build and it's a lot better than it was but unfortunately there's still some issues. Please see the following video: Timestamps So the issue happens less, but is definitely still there. This is still a regression that this PR would introduce, but this PR also fixes almost all of the other issues, so it's very very close!! I still think it'd be a good idea to fix this before merging it in as the issue, when it happens, is quite a serious one. Other less fatal issues visible in the video:
Also, this may not be related to this but putting it here in case it is as it's also pretty fatal: #13126 is a new issue that started to happen in 5.0.0-pre5 (didn't happen in pre4), where CollectionView contents are empty the first time they are shown. Here is a direct link to a video of it as well: Thanks so much for working on these issues. The CollectionView is so close now!! PS. The test users in the test app are random images I found on the net and not real users of any kind. |
I can't get this problem to reproduce, but I might be using a different combination of controls. What's the ItemTemplate you are using in your video? Can you share the XAML? |
Hi.
I’ll provide the XAML soon, but of note is that it happened in only ONE of all
the elements I tested with.
I almost missed it myself as the other speech bubbles seemed to work, and I
can’t say what’s special with that one (except maybe it ending with a blank
line, I’m not at a computer atm so can’t test it).
I tested maybe 30 different speech bubble contents and for some reason that
particular one exposes the problem, and it corrects itself when the CollectionView
is re-layouted (as seen by invoking what would be the on-screen keyboard on
a physical device).
The way it corrects itself is slightly similar to how the ‘keep scrolled to
bottom’ setting corrects itself after scrolling the contents, also visible
in the video.
I’ll get back with more info later.
Thank you.
…On Monday, December 21, 2020, E.Z. Hart ***@***.***> wrote:
0:13: The second to last line, "Asdfasdfasdfasdf" is cropped to one row
only, while in reality it has multiple lines. You can see part of the
second line there.
I can't get this problem to reproduce, but I might be using a different
combination of controls. What's the ItemTemplate you are using in your
video? Can you share the XAML?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12919 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOL6P6GWVSOOSVFARELJCRLSV6FARANCNFSM4T35LRYA>
.
--
|
Fix empty view switching overlap;
@hartez I can not share the exact XAML but I made a very close representation repro project, which is available at #13231. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failing test not related
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Logged a separate issue here #13251
Description of Change
CollectionView on iOS utilizes the UICollectionViewFlowLayout's EstimatedItemSize property to allow virtualization; for items which have not yet been realized, the EstimatedItemSize is used for calculating properties like the UICollectionView's content size (for scrollbars, etc).
When the layout is invalidated, this size is also used for newly inserted items (which have not yet had their actual sizes determined by a cell) and for any items invalidated by insertion/removal. For single DataTemplate scenarios, this is generally fine, since the estimated size calculated from the first item is likely to be close to or exactly the size of subsequent items.
These changes now cache the size of each cell as they are updated from the initial estimated size, and reuses the cached values during future operations.
Issues Resolved
API Changes
None
Platforms Affected
Behavioral/Visual Changes
None
Before/After Screenshots
Not applicable
Testing Procedure
Control Gallery -> CollectionView Gallery -> DataTemplate Galleries -> Varied Size Data Templates
Add/Insert/Remove items - the animation should be smooth, and no items other than the ones being inserted/removed should change size.
Control Gallery -> CollectionView Gallery -> ItemSize Galleries -> Chat Example
Add items - the animation should be smooth, and items should not jump around
PR Checklist