Xamarin.forms: [Bug] CollectionView crashes on adding item

Created on 13 Sep 2019  Â·  46Comments  Â·  Source: xamarin/Xamarin.Forms

Description

Xamarin Forms CollectionView crashes in the newest Xamarin.Forms-nightly versions when adding items with exception:

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.GroupableItemsViewAdapter`2[[Xamarin.Forms.GroupableItemsView, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null],[Xamarin.Forms.Platform.Android.IGroupableItemsViewSource, Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]'.'

However when i change my code to ListView it works again as usual.

Steps to Reproduce

  1. Create a CollectionView
  2. Add items to it

Basic Information

  • Version with issue: 4.4.0.1142-nightly
  • Last known good version: unknown
  • IDE:
  • Platform Target Frameworks:

    • Android: 9.0

collectionview 4 high in-progress Android bug

Most helpful comment

It is fixed but the PR is not merged yet :(
The problem happens if you modify the ObservableCollection by insertions and deletions.
However, you can avoid that by replacing the whole ObservableCollection by creating a clone of the original collection, modify the clone, and assign ItemsSource the new modified clone.
This should resolve the problem temporarily.

All 46 comments

@hudaIT Can you please attach a small project that demonstrates this issue? Thanks!

@hudaIT Can you please attach a small project that demonstrates this issue? Thanks!

I tried to reproduce my issue in a blank project, however i couldn't do it. I think this issue can be closed because i do not know what the excatly the issue is, i only know that it works with ListView while it does not with CollectionView.

I have the same problem.
Here is the exception that I get when I add items to my ObservableCollection

Foundation.MonoTouchException: 'Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).
Native stack trace:
0 CoreFoundation 0x000000011aa078db __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000011b913ac5 objc_exception_throw + 48
2 CoreFoundation 0x000000011aa07662 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000116d0676b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
4 UIKitCore 0x000000012440c7f1 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 16127
5 UIKitCore 0x00000001244085b1 -[UICollectionView _updateRowsAtIndexPaths:updateAction:updates:] + 519
6 UIKitCore 0x000000012440863c -[UICollectionView insertItemsAtIndexPaths:] + 64
7 Farouq.Xamarin.iOS 0x000000010d8534c9 xamarin_dyn_objc_msgSend + 217
8 ??? 0x00000001406875b8 0x0 + 5375555000
'

I found the solution for this particular problem. The problem has actually started when I cleared the data. But it only showed up during Add.
Replacing Items.Clear(); with the following block of code, fixed the problem.

int itemsCount = Items.Count; for (int i = 0; i < itemsCount; i++) Items.RemoveAt(0);
I found the solution here.

But I think it still needs to be fixed in the library and I think this link is a good hint to how to solve it.

I found the solution for this particular problem.

Unfortunately it worked only in one place (one page view) but it did not work in the others. I am still crashing right at the line that adds items to the ObservableCollection

@Elashi Can you please attach a small project that demonstrates this issue? Thanks!

@hudaIT Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts is it possible to provide you a project directly without attaching it in publicity? I have a project where i face this issue in 3 different collectionviews. If it is useful for you i could send you the project directly.

Yes, you can send me a link via email. sahou at microsoft. A zip attachment may get blocked. Thanks!

Here is a small project.
All I did is I created a new Shell project and changed the ListView into CollectionView
Make sure you run it on iOS .
The application will swallow the exception nothing will happen and no items will be displayed.
If you run on Android Emulator , it will run perfectly showing all items.
CollViewCrash.zip

Here is another one , a little bit more complicated but it will show you the exception when you press the Add button.
If it did not show you the exception the first time, try it again. Because it does not show the exception persistently.
RtlCollectionView2.zip

Hm okay i think we actually have 2 different issues here

@Elashi I ran CollViewCrash.zip with 4.4.0.1174-nightly but was unable to reproduce your issue. I see the items. Can you check with that Nuget and see if you still see the issue?

The latest version I have on Nuget is 4.2 yet

The latest version I have on Nuget is 4.2 yet

@Elashi
https://github.com/xamarin/Xamarin.Forms/wiki/Nightly-Builds => for latest builds

We experience the same crash. Tried using the nightly NuGet (4.4.0.1174-nightly) but still occurring: **System.ObjectDisposedException:** 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.GroupableItemsViewAdapter2[[Xamarin.Forms.GroupableItemsView, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null],[Xamarin.Forms.Platform.Android.IGroupableItemsViewSource, Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]'.'

We experience the same crash. Tried using the nightly NuGet (4.4.0.1174-nightly) but still occurring: **System.ObjectDisposedException:** 'Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.GroupableItemsViewAdapter2[[Xamarin.Forms.GroupableItemsView, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null],[Xamarin.Forms.Platform.Android.IGroupableItemsViewSource, Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]'.'

@andyhoyle Have you been able to observe what's the issue? Maby you are able to provide a sample project because i could not.

I've created a new project to try and reproduce the crash but have not succeeded so far. I am going to go back to the original project and pull items out of the XAML one by one until I isolate it.

Replicated in the new project.
Bug7510.zip

I can't reproduce the problem. I have tried several versions (4.3 and 4.4) without success. Could you update (for example to the 4.3.0.819712-pre2 version) and verify it?.

issue7510

Ooops, I just saw your new sample where I reproduce the error. I will check it!.

In the above zip Bug7510.zip the error occurs with version 4.3.0.819712-pre2. If I comment out the overridden OnAppearing then no crash occurs. Rolling back to 4.2.0.815419 crash does not occur.

On further investigation, it's caused by calling new ObservableCollection() more than once.

On further investigation, it's caused by calling new ObservableCollection() more than once.

Ah thank you very much i think that's causing my crash too.

The latest version I have on Nuget is 4.2 yet

@Elashi
https://github.com/xamarin/Xamarin.Forms/wiki/Nightly-Builds => for latest builds

Something went wrong on my machine. No iOS builds successfully now , even a freshly generated Xamarin project. I apologize , I won't be able to test 4.4 .

I had exactly the same issue on 4.3.0.908675 when adding items to ObservableCollection and as mentioned by @andyhoyle it was fixed by preventing calling of new ObservableCollection() more than once.
Exception:

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.GroupableItemsViewAdapter2[[Xamarin.Forms.GroupableItemsView, Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null],[Xamarin.Forms.Platform.Android.IGroupableItemsViewSource, Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]]'. at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42bcf67b56bc4c909c2a5edee682522b>:0 at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42bcf67b56bc4c909c2a5edee682522b>:0 at Android.Support.V7.Widget.RecyclerView+Adapter.NotifyItemInserted (System.Int32 position) [0x00022] in <844c913cb32f4510879031be59eb1dce>:0 at Xamarin.Forms.Platform.Android.AdapterNotifier.NotifyItemInserted (Xamarin.Forms.Platform.Android.IItemsViewSource source, System.Int32 startIndex) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\AdapterNotifier.cs:27 at Xamarin.Forms.Platform.Android.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00041] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ObservableItemsSource.cs:131 at Xamarin.Forms.Platform.Android.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00023] in D:\a\1\s\Xamarin.Forms.Platform.Android\CollectionView\ObservableItemsSource.cs:88 at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in <9e820d206a8d4177b453df9c2fa8d1cc>:0 at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <9e820d206a8d4177b453df9c2fa8d1cc>:0 at System.Collections.ObjectModel.ObservableCollection1[T].InsertItem (System.Int32 index, T item) [0x0001a] in <9e820d206a8d4177b453df9c2fa8d1cc>:0 at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020]

Is there any update on this item. I seem to be getting this Cannot access a disposed object.Object name: 'Xamarin.Forms.Platform.Android.GroupableItemsViewAdapter error when I update an item in an ObservableCollection that is bound to a CollectionView.

I've got Xamarin.Forms v4.3.0.947036 installed. Should I downgrade? if so what version?

@FrazzApps Downgrading to v4.2.0.910310 solved the issue for me.

@samhouts and @jsuarezruiz
I would like to work on this bug if it is not inprogress

@Elashi It looks like we do have a PR open for this already. https://github.com/xamarin/Xamarin.Forms/pull/7670. @jsuarezruiz can provide more info on the status. Thanks!!

Perfect. Then I will go check this PR.
Thanks.

Sent from my iPhone

On Nov 5, 2019, at 12:12 AM, Samantha Houts notifications@github.com wrote:

@Elashi It looks like we do have a PR open for this already. #7670. @jsuarezruiz can provide more info on the status. Thanks!!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

Any workaround without downgrade? I cannot switch to v4.2.0.910310 because I'm already using the RefreshView.

It is fixed but the PR is not merged yet :(
The problem happens if you modify the ObservableCollection by insertions and deletions.
However, you can avoid that by replacing the whole ObservableCollection by creating a clone of the original collection, modify the clone, and assign ItemsSource the new modified clone.
This should resolve the problem temporarily.

@Elashi thanks for the idea. I think in this case I can use regular List and call NotifyPropertyChanged manually after each list change. I'll give a notice if it works.

UPDATE: I did a check and the only way the workaround works is to assign a collection copy to the property. I've used a List instead of an ObservableCollection.

@Elashi I'm using temporary solution which is to assign a collection copy ,it's work,but when i load more data,i think there is a little stuck because of reassignment.Can I do something to solve it?

when will bug fix?

@StefanVam What I really did to get over this problem is stick with 4.2
And to get over @dm-CaT 's problem , I used the plugin https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout

It is very similar to Xamarin's.

Here is an example:
Xamarin's Pull To Refresh in version 4.3 :

   <RefreshView
        Command="{Binding LoadReferencesCommand}"
        IsRefreshing="{Binding IsBusy, Mode=OneWay}">
        <CollectionView
            ItemsSource="{Binding References}">
        </CollectionView>
    </RefreshView>

And this is @jamesmontemagno 's Pull To Refresh plugin :

   <ptr:PullToRefreshLayout
        IsPullToRefreshEnabled="True"
        RefreshCommand="{Binding RefreshReferencesCommand}"
        IsRefreshing="{Binding IsBusy, Mode=OneWay}">
        <CollectionView
            ItemsSource="{Binding References}">
        </CollectionView>
    </ptr:PullToRefreshLayout>

@Elashi Thanks for your reply .I'm using XF version 4.3 now,i think i'll rollback to 4.2 if this bug doesn't fixed in the near future.

I have bad solution, but temporary work for me. I add try and empty catch block around add, insert, remove and clear methods. And inside catch i added todo comment, that remove try/catch after bug fix.

@samhouts Any ETA on when a fix will be available on this issue?

I think this is fixed in latest 4.3.0.991221

Yes i think so too

Yes i think so too

It is not working in iOS versions below iOS 13. Always crashes on adding an item to the ObservabeCollection.

In Android, I'm not facing any issues as of now.

I can confirm this, it still fails on iphone6 ios 12

I encounter this error as well in a simple app that contains a Flyout item with a collection view. When navigating to another Flyout item and returning to the previous Flyout item with the collection view, the error is raised. I see this happening in the iPhone 11 simulator (iOS 13.3) and assume it happens on a device as well.

At the moment I don't know if there are any viable work-arounds for my situation.

@wolf81 I have the same problem, and I test it also in a physical iPhone 8 with iOS 13.4.1.

I have a CollectionView with a Header and Footer. The CollectionView is on the main screen, and it loads OK when open app. But as wolf81 describes, when go to another screen and get back to the screen with CollectionView it crashes:

at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:449 at UIKit.UICollectionViewController.get_CollectionView () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UICollectionViewController.g.cs:1102 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].RemeasureLayout (Xamarin.Forms.VisualElement formsElement) [0x00076] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:333
at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].HandleFormsElementMeasureInvalidated (Xamarin.Forms.VisualElement formsElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:348 at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].HandleFormsElementMeasureInvalidated (Xamarin.Forms.VisualElement formsElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:208
at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].OnFormsElementMeasureInvalidated (System.Object sender, System.EventArgs e) [0x0000a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:342 at Xamarin.Forms.VisualElement.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x0000b] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:824 at Xamarin.Forms.Grid.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Grid.cs:230 at Xamarin.Forms.Layout.OnChildMeasureInvalidated (Xamarin.Forms.VisualElement child, Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x00086] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:351 at Xamarin.Forms.Layout.OnChildMeasureInvalidated (System.Object sender, System.EventArgs e) [0x00013] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:212 at Xamarin.Forms.VisualElement.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x0000b] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:824 at Xamarin.Forms.VisualElement.set_IsPlatformEnabled (System.Boolean value) [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:539 at Xamarin.Forms.Platform.iOS.Platform+<>c.<.cctor>b__62_0 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:31 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311 at Xamarin.Forms.Platform.iOS.Platform.SetRenderer (Xamarin.Forms.VisualElement bindable, Xamarin.Forms.Platform.iOS.IVisualElementRenderer value) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:239 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00045] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:100 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:277
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228 at Xamarin.Forms.Platform.iOS.TemplateHelpers.CreateRenderer (Xamarin.Forms.View view) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\TemplateHelpers.cs:17 at Xamarin.Forms.Platform.iOS.TemplateHelpers.RealizeView (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, Xamarin.Forms.ItemsView itemsView) [0x00046] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\TemplateHelpers.cs:45 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].UpdateView (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, UIKit.UIView& uiView, Xamarin.Forms.VisualElement& formsElement) [0x00030] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:368
at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].UpdateSubview (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, System.nint viewTag, UIKit.UIView& uiView, Xamarin.Forms.VisualElement& formsElement) [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:116 at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].UpdateFooterView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:94
at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer2[TItemsView,TViewController].SetUpNewElement (TItemsView newElement) [0x00010] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewRenderer.cs:48 at Xamarin.Forms.Platform.iOS.SelectableItemsViewRenderer2[TItemsView,TViewController].SetUpNewElement (TItemsView newElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\SelectableItemsViewRenderer.cs:34
at Xamarin.Forms.Platform.iOS.ItemsViewRenderer2[TItemsView,TViewController].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x0000c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewRenderer.cs:36
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00122] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:290 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:277 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:245
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIViewController.g.cs:3172
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:111
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:127
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.LoadRenderers () [0x00028] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:150
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.ViewDidLoad () [0x0006e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:67
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at QueHH.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jcsoluciones/app_queHH/QueHH/Codigo/LineaBase_ConShell/QueHH/QueHH.iOS/Main.cs:17`

@wolf81 I have the same problem, and I test it also in a physical iPhone 8 with iOS 13.4.1.

I have a CollectionView with a Header and Footer. The CollectionView is on the main screen, and it loads OK when open app. But as wolf81 describes, when go to another screen and get back to the screen with CollectionView it crashes:

at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/Foundation/NSObject2.cs:449 at UIKit.UICollectionViewController.get_CollectionView () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UICollectionViewController.g.cs:1102 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].RemeasureLayout (Xamarin.Forms.VisualElement formsElement) [0x00076] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:333
at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].HandleFormsElementMeasureInvalidated (Xamarin.Forms.VisualElement formsElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:348 at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].HandleFormsElementMeasureInvalidated (Xamarin.Forms.VisualElement formsElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:208
at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].OnFormsElementMeasureInvalidated (System.Object sender, System.EventArgs e) [0x0000a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:342 at Xamarin.Forms.VisualElement.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x0000b] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:824 at Xamarin.Forms.Grid.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Grid.cs:230 at Xamarin.Forms.Layout.OnChildMeasureInvalidated (Xamarin.Forms.VisualElement child, Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x00086] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:351 at Xamarin.Forms.Layout.OnChildMeasureInvalidated (System.Object sender, System.EventArgs e) [0x00013] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:212 at Xamarin.Forms.VisualElement.InvalidateMeasureInternal (Xamarin.Forms.Internals.InvalidationTrigger trigger) [0x0000b] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:824 at Xamarin.Forms.VisualElement.set_IsPlatformEnabled (System.Boolean value) [0x0001c] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:539 at Xamarin.Forms.Platform.iOS.Platform+<>c.<.cctor>b__62_0 (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:31 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334 at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311 at Xamarin.Forms.Platform.iOS.Platform.SetRenderer (Xamarin.Forms.VisualElement bindable, Xamarin.Forms.Platform.iOS.IVisualElementRenderer value) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:239 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x00045] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:100 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:277
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228 at Xamarin.Forms.Platform.iOS.TemplateHelpers.CreateRenderer (Xamarin.Forms.View view) [0x0001f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\TemplateHelpers.cs:17 at Xamarin.Forms.Platform.iOS.TemplateHelpers.RealizeView (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, Xamarin.Forms.ItemsView itemsView) [0x00046] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\TemplateHelpers.cs:45 at Xamarin.Forms.Platform.iOS.ItemsViewController1[TItemsView].UpdateView (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, UIKit.UIView& uiView, Xamarin.Forms.VisualElement& formsElement) [0x00030] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:368
at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].UpdateSubview (System.Object view, Xamarin.Forms.DataTemplate viewTemplate, System.nint viewTag, UIKit.UIView& uiView, Xamarin.Forms.VisualElement& formsElement) [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:116 at Xamarin.Forms.Platform.iOS.StructuredItemsViewController1[TItemsView].UpdateFooterView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:94
at Xamarin.Forms.Platform.iOS.StructuredItemsViewRenderer2[TItemsView,TViewController].SetUpNewElement (TItemsView newElement) [0x00010] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewRenderer.cs:48 at Xamarin.Forms.Platform.iOS.SelectableItemsViewRenderer2[TItemsView,TViewController].SetUpNewElement (TItemsView newElement) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\SelectableItemsViewRenderer.cs:34
at Xamarin.Forms.Platform.iOS.ItemsViewRenderer2[TItemsView,TViewController].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x0000c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewRenderer.cs:36
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00122] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:290 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x000de] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:277 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:157
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:99
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:48
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:245
at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIViewController.g.cs:3172
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:111
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:127
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00014] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:228
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.LoadRenderers () [0x00028] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:150
at Xamarin.Forms.Platform.iOS.ShellSectionRootRenderer.ViewDidLoad () [0x0006e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ShellSectionRootRenderer.cs:67
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at QueHH.iOS.Application.Main (System.String[] args) [0x00001] in /Users/jcsoluciones/app_queHH/QueHH/Codigo/LineaBase_ConShell/QueHH/QueHH.iOS/Main.cs:17`

Updating to Xamarin.Forms 4.6.0.726 solved the problem

Was this page helpful?
0 / 5 - 0 ratings