-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Bug] Regression: 5.0.0-pre5 often fails to draw dynamically loaded collection view content #13126
[Bug] Regression: 5.0.0-pre5 often fails to draw dynamically loaded collection view content #13126
Comments
After running this test tens of more times I unfortunately have to say that just removing the IsVisible property from the collection view does not solve the problem, but merely makes the 'blank content' issue just happen less frequently. So I suspect there is a race condition in there now, where toggling IsVisible just makes the error happen more often. I literally just populate the contents of the collection view inside the page's vm like this in an async command: // load chatRoomsEx list here...
using (this.ChatRooms.BeginMassUpdate())
{
this.ChatRooms.Clear();
this.ChatRooms.AddRange(chatRoomsEx);
} And the collection view displays ChatRooms as such: <CollectionView
ItemSizingStrategy="MeasureFirstItem"
ItemsSource="{Binding ChatRooms}"
IsVisible="{Binding ChatRooms.Count, Converter={StaticResource IsNotZeroConverter}}"> ChatRooms is an OptimizedObservableCollection, https://github.com/xamarinhq/xamu-infrastructure/wiki/OptimizedObservableCollection. There is no reason why this shouldn't work with pre-5. This happens in one of the two last collection views I have in the app as unfortunately there's so many problems with them, and I probably have to convert this to a list view now as well :( |
I downgraded XF back to 5.0.0-pre4 and now the collection views display their contents again. |
#11853 seems to share characteristics with this issue (IsVisible toggling affecting result, AddRange manipulation not working etc.), but I failed to see whether any changes were done for 5.0.0 or if those breaking fixes were merely backported to 4.8.0. @jsuarezruiz @hartez Will this regression get fixed in the next preview release of 5.0.0? |
Here is a video of the issue: The same page with a CollectionView is opened twice:
This worked in 5.0.0-pre4 but not in pre5. PS. The test users in the test app are random images I found on the net and not real users of any kind. Thanks. |
Have you considered using the EmptyView property for this? Also, any chance you could provide a small repro project so we can see exactly how your converter and bindings are wired up, and the layout of your page? That would go a long way toward finding out where the bug is. |
Thanks for the reply. Regarding EmptyView - I tried using it but it's a bit too buggy...
Regarding this issue -- it looks to me that pre5 and higher no longer refresh the collection view contents while hidden, and the order in which the refresh and visibility toggling happen seem to be random, exposing this regression. 5.0.0-pre4 was the last version where toggling the IsVisible flag on a collection view worked in conjunction with its data being loaded. |
@hartez Please find enclosed a repro project of the issue: Issue13126.zip When the repro is first run, the EmptyView will be displayed (which is wrong as the collection view has 20 elements): Any of these three steps will make the collection view draw its contents and fix the issue:
This is how it should look like: Do you think this could be fixed quite soon as I can no longer update Xamarin.Forms and I'm stuck with pre-4 until this is fixed? I think this is quite a dangerous bug as it will surely waste many a developer's valuable time, and at least for me makes the CollectionView unfortunately completely unusable. Thank you. |
@Redth @hartez I think #13203 is a duplicate of this one. It was closed as fixed, but I have tested with the latest nightly build of Xamarin.Forms (5.0.1.1917-nightly) and this issue still happens. I have provided a simple repro in this bug report (#13126 (comment)), and also a more involved repro at #13231. This issue is still keeping me on Xamarin.Forms 5.0.0-pre4 as it's the last working version. I would really need this to be fixed as all my CollectionViews show up as empty atm. Thank you so much for your help/insights into this! |
I found a workaround for now that allows me to update to XF5-pre5 and later: After doing a batch edit/toggling visibility on a CollectionView, force set the ItemsSource to null and back in your code-behind: var items = this.myCollectionView.ItemsSource;
this.myCollectionView.ItemsSource = null;
this.myCollectionView.ItemsSource = items; Needless to say this issue that was introduced in 5.0.0-pre5 needs to be fixed, but at least the above should allow your app to function in the interim. |
I spoke too soon - apparently something is different between this case and #13551; with the visibility converter tied to the view model value, the collection is not being displayed. Looking into that now. |
CollectionView updates while CollectionView is hidden; fixes #13126
CollectionView updates while CollectionView is hidden; fixes #13126
Okay, second time's the charm. |
Thank you!!! |
…ble (#13678) fixes #13126 * Allow item source updates while CollectionView is hidden; prevent CollectionView updates while CollectionView is hidden; fixes #13126 * Fix bug where measurement cell content is applied to the wrong cell Only force layout on transition from invisible to visible Move cell size cache to layout and clear cache on size change (e.g., rotation) Use ItemsView size for constraints when possible; * Add test for Reset situation; fix bug with Reset before CollectionView is visible;
The fix introduced another regression... |
Description
After updating to 5.0.0-pre5 some of my collection views don't show up the first time they are loaded.
I often employ the following pattern:
IsVisible="{Binding ChatRooms.Count, Converter={StaticResource IsNotZeroConverter}}"
, where the same ObservableCollection is used as its content.The intent is to show an informational message if there's no content in the collection view, or else show the collection view's contents.
This has worked flawlessly until updating to pre5. What happens now is that collection views content is never made visible when the content has finished loading (IsVisible goes to true by the ChatRooms collection filling up after loading). The collection view's headers are shown so the view itself does get drawn, but the content inside it does not, it is drawn as if it had zero items.
If I load the page again then it displays fine, but safe to say I can't have an app where the default is to show blank content. On consecutive loads the data is cached on the client so it's instantly available to the content view.
I suspect this is caused #12017, which definitely takes XF to a better direction but I think it has a bug in it.
If I remove the IsVisible=xxx on the collection view it does draw its contents properly, but this I can't do as it breaks the logic of the page. Is this some kind of race condition with drawing the items when IsVisible toggles to true?
Nevertheless this is pretty fatal as most of my pages are now empty.
Thank you.
EDIT: please read my follow up reply
Basic Information
Environment
Show/Hide Visual Studio info
Workaround
None. Can't just have it visible at all times as it contains headers and stuff that break the layout.
The text was updated successfully, but these errors were encountered: