Xamarin.forms: [Bug] [iOS] Cannot access a disposed object. Object name: 'GroupableItemsViewController`1

Created on 30 Oct 2019  路  91Comments  路  Source: xamarin/Xamarin.Forms

Description

A collection view with header causes a crash after navigating via the shell flyout.
The bug is iOS only. On Android it works fine.

The app wont crash if you use tabs.

Steps to Reproduce

  1. Open the App
  2. Use the shell flyout to navigate to Page 2
  3. Use the shell flyout to navigate back to Page 1

--> The App will crash

Expected Behavior

Not crashing.

Actual Behavior

Throws:

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'GroupableItemsViewController`1'.'
and crashes.

Basic Information

  • Version with issue: 4.3.0.947036, 4.3.0.908675, ..., 4.4.0.991265
  • Last known good version: 4.2.0.910310
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:

    • iOS: 13.1, 13.2 (Probbably other versions too)

Reproduction Link

BugExample.zip

collectionview high high impact iOS 馃崕 bug

Most helpful comment

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

All 91 comments

Any ideas for a workaround?

Same behaviour with a TabBar. Is there any investigation ongoing?

AppShell.xaml



<!-- Your Pages -->
<TabBar Route="main">
    <Tab Title="Computers" Icon="computers.png" Route="computers">
        <ShellContent ContentTemplate="{DataTemplate computer:ComputersRootPage}" 
                      Title="Root"
                      Route="root"
                      />
    </Tab>
    <Tab Title="Favorites" Icon="favorites.png">
        <ShellContent ContentTemplate="{DataTemplate local:FavoritesPage}" />
    </Tab>
    <Tab Title="Active" Icon="active.png">
        <ShellContent ContentTemplate="{DataTemplate local:ActivePage}" />
    </Tab>
    <Tab Title="Users" Icon="users.png">
        <ShellContent ContentTemplate="{DataTemplate local:UsersPage}" />
    </Tab>
    <Tab Title="Account" Icon="account.png">
        <ShellContent ContentTemplate="{DataTemplate local:AccountPage}" />
    </Tab>
</TabBar>

Debug Log

[UICollectionView] 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). - will perform reloadData. UICollectionView instance: ; layer = ; contentOffset: {0, -100}; contentSize: {414, 45}; adjustedContentInset: {100, 0, 0, 0}; layout: ; dataSource: >; currentUpdate: [UICollectionViewUpdate - 0x7fe2e5e1
c620: old: new items:<(
"I(0,0)"
)>]

Exception Message

Cannot access a disposed object.
Object name: GroupableItemsViewController

I just got this same error from an otherwise-working app revision that has been out for a month.

Occurred on iOS 12.4.1. Report from AppCenter, so details limited and I haven't been able to reproduce it. Most people seem to never encounter it.

@BioTurboNick which version of Xamarin Forms do you use? Because your problem looks like something else.
The error above is pretty easy to reproduce and will happen every time you switch between pages.

Hmm maybe so. I'm on 4.2.0.848062. Still, I had never seen an ObjectDisposedException from GroupableItemsViewController before now, ever.

I tested this bug on 4.2.0.9... and it worked fine. Probably this is something else?

Regarding XF SDK Version: 4.3.0.947036 (latest stable)

I filed a new issue because it's related but happens on a TabBar: https://github.com/xamarin/Xamarin.Forms/issues/8394

same issue come but without grouping. in forms version 4.3

I had the problem with a collection view with a footer. Removing the footer appears to have resolved the problem.

Still getting this issue on 4.4.0.991265 I don't have a header or footer in my CollectionView and it still crashes.

Untitled

I get this bug with a simple (I think) collection view, I'm using Xamarin Forms 4.4.0.991265, with a listview it works fine

  <CollectionView Grid.Row="0" ItemsSource="{Binding Currencies}" IsGrouped="False">
                <CollectionView.ItemsLayout>
                   <GridItemsLayout Orientation="Horizontal" />
                </CollectionView.ItemsLayout>
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid Padding="10">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="100" />
                                <RowDefinition Height="100" />
                            </Grid.RowDefinitions>
                            <Label Grid.Row="0" 
                                   Text="{Binding CCY}" 
                                   FontAttributes="Bold"
                                   FontFamily="AppleSDGothicNeo-UltraLight" 
                                   />
                            <Label Grid.Row="1"
                                   FontFamily="AppleSDGothicNeo-UltraLight" 

                                   TextColor="{Binding Path=Amount, Converter={StaticResource ValueToColorConverter}}"
                                   Text="{Binding ., Converter={StaticResource CurrencyConverter}}"

                                    />
                        </Grid>

                    </DataTemplate>
                </CollectionView.ItemTemplate>
        </CollectionView>

It renders the first time but when I do a 'hot reload' it breaks with:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GroupableItemsViewController1'. at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/Foundation/NSObject2.cs:449 at UIKit.UIViewController.get_IsViewLoaded () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/UIViewController.g.cs:2075 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.NotLoadedYet () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:142 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x0000d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:147 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00023] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:100 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 /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263
at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 at System.Collections.ObjectModel.ObservableCollection1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196
at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:71
at O.ViewModels.CashSummaryViewModel.ExecueLoadItemsCommand (System.Boolean ForceRefresh) [0x00103] in /Users/chris/Projects/O/ViewModels/CashSummaryViewModel.cs:43
2019

After updating to 4.4.0.991265, I'm running into this again - even on collection views without headers or footers. :(

Please fix this urgently. I also have this issue. Cannot use shell in production because of it. Should be marked critical.

Steps to Reproduce
Open the App
Use the shell flyout to navigate to Page 2
Use the shell flyout to navigate back to Page 1
--> The App will crash

Same problem. Why is this not fixed yet?

What @jsiemens said 馃憜

I'm also facing this issue in a collectionview with or without header and footer. Using Xamarin.Forms 4.4.0.991640

@hartez Thanks. This is a critical bug that makes shell unusable on iOS.

I have the same issue and I can't publish a buggy App.... Please fix it !

Same issue here.

Same issue here

Same issue on 4.4.0.991640 without shell, without a header, and without a footer.

Also occurs using a CarouselView which I imagine has the same stuff under the hood

Come on, Xamarin team... Is it really acceptable to have a crashing bug in production for 5 months?

@PureWeen @hartez @samhouts

Never had this bug before 4.5.
After updating to 4.5 this bug appears on a CollectionView (without Shell).

Same Problem here with Hot-Reload:
In my case a ListView

The View:
`


    <StackLayout>
        <ListView x:Name="LvAbwesenheiten" BackgroundColor="Transparent" 
                  HasUnevenRows="True" 
                  ItemTemplate="{StaticResource AbwesenheitTemplateSelector}"
                  SeparatorVisibility="None"
                  />
  </StackLayout>

`

The ViewCell (the Template):
` xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DATAflor.Team.DFViews.Urlaub.CustomCells.AbwesenheitCell">

    <StackLayout x:Name="StackLayoutMain" 
                 Orientation="Horizontal" 
                 HorizontalOptions="Fill" 
                 Padding="10" 

                 >
        <StackLayout.Resources>
            <Style x:Key="LabelStyleZeitraum" TargetType="Label">
                <Setter Property="TextColor" Value="{DynamicResource TextOnBackgroundColor}"/>
                <Setter Property="FontSize" Value="15"/>
            </Style>
            <Style x:Key="LabelStyleText" TargetType="Label">
                <Setter Property="TextColor" Value="{DynamicResource TextOnBackgroundColor}"/>
                <Setter Property="FontSize" Value="13"/>
            </Style>
        </StackLayout.Resources>
        <!--BackgroundColor="{Binding Path=BackgroundColor}"-->

        <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand">

            <StackLayout Orientation="Horizontal">
                <Label Text="{Binding Von, StringFormat='{0:dd.MM.yyyy}'}" Style="{StaticResource LabelStyleZeitraum}" />
                <Label Text=" - " Style="{StaticResource LabelStyleZeitraum}"/>
                <Label Text="{Binding Bis, StringFormat='{0:dd.MM.yyyy}'}" Style="{StaticResource LabelStyleZeitraum}"/>
            </StackLayout>

            <Label Text="{Binding Text}" 
                   Style="{StaticResource LabelStyleText}"
                   />


        </StackLayout>



    </StackLayout>
</ViewCell.View>

`

Whenever i change something in the Template, hit Save to initiate the hot-reload, the error happens (iOS 13 inside Simulator; iOS 12 on a real Device)

Doesn't happen with every Listview/Template and i don't know what the difference is or how to workaround it... until now it only happens with Hot-Reload which is annoying but not critical - but when i read that some of you have this at normal runtime i'm a bit afraid ...

Here is a Stack-Trace:

`Cannot access a disposed object.
Object name: 'DefaultRenderer'.

at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.3.0/src/Xamarin.iOS/Foundation/NSObject2.cs:449
at UIKit.UIView.set_Frame (CoreGraphics.CGRect value) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.3.0/src/Xamarin.iOS/UIView.g.cs:3684
at Xamarin.Forms.Platform.iOS.ViewCellRenderer+ViewTableCell.LayoutSubviews () [0x000a5] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Cells\ViewCellRenderer.cs:103
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_Int64(intptr,intptr,intptr,long)
at UIKit.UITableView.ReloadRows (Foundation.NSIndexPath[] atIndexPaths, UIKit.UITableViewRowAnimation withRowAnimation) [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.8.3.0/src/Xamarin.iOS/UITableView.g.cs:824
at Xamarin.Forms.Platform.iOS.CellRenderer+<>c__DisplayClass8_0.b__0 (System.Object sender, System.EventArgs e) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Cells\CellRenderer.cs:106
at Xamarin.Forms.Cell.OnForceUpdateSizeRequested () [0x00076] in D:\a\1\s\Xamarin.Forms.Core\Cells\Cell.cs:234 `

i also have this problem in my app. removing the footer of the collectionview in the corresponding page with an invisible boxview of height 100 (just to add some space at the bottom of the view) resolves the problem.
there is another thing that works fine: i have multiple flyoutitem definitions in my shellpage. if i only have one flyoutitem definition, this issue is not appearing. so if you can manage to design your shell flyout so that every shellcontent is in one flyoutitem, the issue is resolved.

@Genfood on your sample project, the problem ist the header of the collectionview in ItemsPage. removing it resolves the problem, but it should not crash with or without setting a header. another thing you can do, like mentioned above, is to combine all flyoutitems into one. then it will work as well.

this nasty bug needs to be fixed

@samhouts When will the fix be released?

@samhouts I just tried that version and the problem still persists.

System.ObjectDisposedException
Message=Cannot access a disposed object.
Object name: 'WkWebViewRenderer'.

I am also facing same issue

@samhouts This is not fixed.

I tested it in the newly released 4.6 stable. And it seems to be fixed. 馃帀
At least the bug example I attached to this issue works now.

@samhouts It's fixed if you have a CollectionView but not if you have a WebView. That is still broken. Probably a few others too.

@samhouts I just tried that version and the problem still persists.

System.ObjectDisposedException
Message=Cannot access a disposed object.
Object name: 'WkWebViewRenderer'.

@g4mb10r That's a different error from a different control than the original posted issue. ObjectDisposedExceptions can have many causes.

Please open a new issue with your information (that it's a WkWebviewRenderer) and please include any other info you have (stack traces, a repro project if possible).

@samhouts I am still experiencing this issue with CollectionViews in v1.6. Here is the trace:

at Foundation.NSObject.get_SuperHandle () [0x00012] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSObject2.cs:449

at UIKit.UIView.set_Frame (CoreGraphics.CGRect value) [0x00024] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIView.g.cs:3685

at Xamarin.Forms.Platform.iOS.ItemsViewController`1[TItemsView].LayoutEmptyView () [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewItemsViewController.cs:318

at Xamarin.Forms.Platform.iOS.ItemsViewController`1[TItemsView].ViewWillLayoutSubviews () [0x00046] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionViewItemsViewController.cs:161

at Xamarin.Forms.Platform.iOS.StructuredItemsViewController`1[TItemsView].ViewWillLayoutSubviews () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\StructuredItemsViewController.cs:78

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.18.2.1/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.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65

at Logbook.iOS.Application.Main (System.String[] args) [0x00001] in C:\Code\Logbook\Logbook\Logbook.iOS\Main.cs:17

I have been unable to pinpoint the exact thing that is causing the problem but I have CollectionViews in several tabs within flyoutitem using Shell. Each CollectionView uses group headers.

Loading a tab with a CollectionView is fine, then a second one is also fine. The crash occurs when I try to navigate back to a previously viewed one.

I am working on trying to replicate this in a sample project but have not been able to so far. Also I am not experiencing any issues on Android.

EDIT

I have opened a new Issue #10953 as I seem to have found the cause. Not sure if it is related to the original poster's Issue.

This is still broken in v4.7.0.1080 on iOS. Android is fine.

3x CollectionViews on 3x different pages, no headers or footers. Not using Shell, just normal ContentPages.

Hot-Reload or not, it doesn't matter. First collection-view population is fine. Refreshing it causes the crash. And this is probably the simplest implementation of collectionview there is.

All of them break exactly the same way when the underlying ObservableCollection is cleared and then repopulated.

I can't believe this is still borked after nearly 9 months.

If it helps anyone else who comes here after this has been closed-but-not-fixed, I've noticed that if I introduce a very short delay (>100ms) between clearing and repopulating that does seem to help. I'm not a fan of introducing delays to 'fix' things tho.

If you try and clear it using a different method, e.g. while observablecollection.count > 0 do observablecollection.removeat(0) (to clear it) and then try to repopulate too quickly, sometimes you'll get a different exception from SemaphoreSlim:

System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum

Just the same @wislon 鈽癸笍, one that can add that reproduce it at iOS v12.4 but in v13.5 works without crushes

Update:

With version Xamarin.Forms 4.6.0.1180 this bug is not reproducible at iOS v12.4

I'm still getting this running the latest version of Xamarin.Forms running IOS 12.4.5

I can repro this running iOS 12.4.1 (but not 13.x) and Xamarin.Forms 4.7. Please open the bug up again.

@robintschroeder , @daves1992 can you reproduce using the BugExample ?

@rmarinho Yes, just tested on an Iphone 6 running 12.4.5 and was able to repro using BugExample first time

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'GroupableItemsViewController`1'.'

I tested with 4.8 on iOS 12.2 Simulator and seems to work.

My bad I forgot to update Xamarin.Forms in the sample. I updated to 4.8 and haven't been able to reproduce on the sample or my app since... ill keep an eye as it didn't repro every time the other day and I was 100% on 4.7.X

the bug is still exists on xamarin 4.8 (iphone 6, ios 12.4.6)

@rkarban do you have a repo? i just tested and wasn't able to reproduce it .

@rmarinho unfortunately the repo is private, and I can not give access
here is stack trace
NSObject.get_SuperHandle ()
UICollectionViewController.get_CollectionView ()
ItemsViewController`1[TItemsView].GetPrototype ()
ItemsViewLayout.DetermineCellSize ()
ListViewLayout.ConstrainTo (CoreGraphics.CGSize size)
ItemsViewLayout.UpdateConstraints (CoreGraphics.CGSize size)
ItemsViewLayout.InvalidateLayout ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

BugExample.zip

@rmarinho I managed to replicate it by changing the sample slightly.

I added a 100ms delay to setting the Items property.

Iphone 6
IOS 12.4.5
Xamarin.Forms 4.8

    ObservableCollection<string> items;

    public ObservableCollection<string> Items
    {
        get { return items; }
        set 
        {
            SetProperty(ref items, value);
        }
    }

    public Command LoadItemsCommand { get; set; }

    public ItemsViewModel()
    {
        Title = "Browse";
        _= getItems();
    }

    async Task getItems()
    {
        await Task.Delay(100);
        Items = new ObservableCollection<string>
        {
            "Test",
            "Test",
            "Test",
            "Test",
            "Test",
        };
    }

I have the same issue on ios 12 even with Xamarin Forms 4.8. Collectionview is crashing on these devices. We need to reopen this issue.

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

Thanks for sharing. I'll try this. We also see a huge amount of crashes regarding this issue.

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

some heroes don't wear capes

@rmarinho @samhouts can we reopen this bug? I managed to replicate again using an adjusted version of the sample see above and it seems more people are having the issue.

I'm having the same issue too even with the latest Forms. No Shell, no Headers or Footers.

I am having the same issue, but with a ListView on iPad running iOS 12.4.8 and iPhone running iOS 12.4.1, but not on devices on iOS 13. I am on Xamarin Forms 4.7 SR5 targeting iOS 13.4.

Xamarin Exception Stack:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GroupableItemsViewController`1'.
  at Foundation.NSObject.get_SuperHandle () <0x101941484 + 0x0009c> in <698888335fd24bdca1317448cda6f409#1ffb13f9a443e65aad81d66c194bad70>:0
  at UIKit.UICollectionViewController.get_CollectionView () <0x10191f038 + 0x0002f> in <698888335fd24bdca1317448cda6f409#1ffb13f9a443e65aad81d66c194bad70>:0
  at Xamarin.Forms.Platform.iOS.ItemsViewController`1[TItemsView].GetPrototype () <0x101e787f0 + 0x00113> in <c02bcffd65214bdd87ba2c816440c864#1ffb13f9a443e65aad81d66c194bad70>:0
  at Xamarin.Forms.Platform.iOS.ItemsViewLayout.DetermineCellSize () <0x101e7fde0 + 0x000a3> in <c02bcffd65214bdd87ba2c816440c864#1ffb13f9a443e65aad81d66c194bad70>:0
  at Xamarin.Forms.Platform.iOS.ListViewLayout.ConstrainTo (CoreGraphics.CGSize size) <0x101e80efc + 0x00037> in <c02bcffd65214bdd87ba2c816440c864#1ffb13f9a443e65aad81d66c194bad70>:0
  at Xamarin.Forms.Platform.iOS.ItemsViewLayout.UpdateConstraints (CoreGraphics.CGSize size) <0x101e7f944 + 0x0006b> in <c02bcffd65214bdd87ba2c816440c864#1ffb13f9a443e65aad81d66c194bad70>:0
  at Xamarin.Forms.Platform.iOS.ItemsViewLayout.InvalidateLayout () <0x101e80ac0 + 0x00043> in <c02bcffd65214bdd87ba2c816440c864#1ffb13f9a443e65aad81d66c194bad70>:0
  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) <0x1018fa618 + 0x0003f> in <698888335fd24bdca1317448cda6f409#1ffb13f9a443e65aad81d66c194bad70>:0
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1018fa570 + 0x00053> in <698888335fd24bdca1317448cda6f409#1ffb13f9a443e65aad81d66c194bad70>:0
  at FieldEdge.Mobile.Tablet.iOS.Application.Main (System.String[] args) <0x10054cbf8 + 0x00033> in <ca210f5f974b45669b487b30759435fc#1ffb13f9a443e65aad81d66c194bad70>:0

Any workarounds for ListView?

@rd09 ListView does not use a GroupableItemsViewController. You sure you're not using a CollectionView?

@rd09 ListView does not use a GroupableItemsViewController. You sure you're not using a CollectionView?

Thank you for the heads up, you are correct. I somehow assumed that but after going through the source code and verifying, I decided to apply the workaround that @l0gaw posted and it worked.

Using @l0gaw workaround fixed the crashes I was seeing previously, but now I am getting another crash with the same exception but a different stack trace:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GroupableItemsViewController`1'.
  at Foundation.NSObject.get_SuperHandle () <0x101d8f3c0 + 0x0009c> in <698888335fd24bdca1317448cda6f409#b6c34173f62d398ef7bfb32c87027461>:0
  at UIKit.UIViewController.get_IsViewLoaded () <0x101d671f4 + 0x0000f> in <698888335fd24bdca1317448cda6f409#b6c34173f62d398ef7bfb32c87027461>:0
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.ReloadRequired () <0x1022cfc28 + 0x00017> in <f363ad1ddcfd4686ace46d6cfc5b07cf#b6c34173f62d398ef7bfb32c87027461>:0
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Remove (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) <0x1022d0e9c + 0x0013b> in <f363ad1ddcfd4686ace46d6cfc5b07cf#b6c34173f62d398ef7bfb32c87027461>:0
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) <0x1022d00a8 + 0x001bf> in <f363ad1ddcfd4686ace46d6cfc5b07cf#b6c34173f62d398ef7bfb32c87027461>:0
  at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) <0x1022007b0 + 0x00417> in <f363ad1ddcfd4686ace46d6cfc5b07cf#b6c34173f62d398ef7bfb32c87027461>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) <0x100c355e8 + 0x0005b> in <624bcc4ce53347508a7b8fa821d78da4#b6c34173f62d398ef7bfb32c87027461>:0
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () <0x101d8d5fc + 0x0002f> in <698888335fd24bdca1317448cda6f409#b6c34173f62d398ef7bfb32c87027461>:0
  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) <0x101d48708 + 0x0003f> in <698888335fd24bdca1317448cda6f409#b6c34173f62d398ef7bfb32c87027461>:0
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x101d48660 + 0x00053> in <698888335fd24bdca1317448cda6f409#b6c34173f62d398ef7bfb32c87027461>:0
  at FieldEdge.Mobile.Tablet.iOS.Application.Main (System.String[] args) <0x1009aa488 + 0x00033> in <044acf8dc1f745b3bc6b51b04b6a2bae#b6c34173f62d398ef7bfb32c87027461>:0

We're also seeing this on iOS 12 only, and haven't found a workaround so far.

I have this bug too in iPad

  • XAMARIN 4.7
  • iOS 13.5.1

SIGABRT: Cannot access a disposed object. Object name: 'ParentingViewController'.

NSObject.get_SuperHandle ()
UIViewController.get_NavigationItem ()
NavigationRenderer+<>c__DisplayClass79_0.<SetMasterLeftBarButton>b__0 (UIKit.UIImage icon)
ImageElementManager.ApplyNativeImageAsync (Xamarin.Forms.BindableObject bindable, Xamarin.Forms.BindableProperty imageSourceProperty, System.Action`1[T] onSet, System.Action`1[T] onLoading, System.Threading.CancellationToken cancellationToken)
NavigationRenderer.SetMasterLeftBarButton (UIKit.UIViewController containerController, Xamarin.Forms.MasterDetailPage masterDetailPage)
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

@l0gaw Do I need to implement only CustomRenderer in the iOS project or do I need something else in the main project?

@matheuscschenfeld In the iOS project

Also still experiencing this problem, workaround doesn't fix this

edit
I fixed my problem. I was doing a binding to a model command instead of viewmodel command. This binding was not updated when switching back and forth between viewmodels. So instead of dismissing a collection item on the new viewmodel source, it wanted to remove an item from the collection that was already disposed.
Not having an issue anymore when changing the binding to the viewmodel instead of model.

You have to be careful using the workaround that was posted because the line that sets SelectedItem to null triggers the SelectedItem Event, so if you have a two way binding set to that property and are not checking for null it will cause an exception. I removed the line completely since I don't think it is necessary for the workaround.

@samhouts Any update on whether this will be picked up very soon. The same issue is also happening in Listview. Form version 4.7.0.1080

I am guessing this may be fixed on Xamarin.Forms 5.x or maybe wait until MAUI. I hope to be wrong

I'm reproducing this issue as well on Xamarin 4.8 on iOS simulator

@samhouts @hartez Many people are still reporting this rather large bug. The scope of this bug was too small to encapsulate the actual issue.

It's quite impressive this wasn't fixed yet, i'm also having this bug, the CollectionView never worked properly on iOS

@l0gaw 's workaround used to work, but now it doesn't. Can't tell if it is from the last iOS update, or not, but it is getting really annoying - crashes everywhere from simple update/clear.

@mduchev I'm seeing this as well. It's happening on both iOS 13 and 14. The only thing that changed for me was moving to Xamarin.iOS 14. Trying to see if I can come up with a workaround now.

Specifically, here's the stack I see now:

NSObject.get_SuperHandle ()
UIViewController.get_IsViewLoaded ()
ObservableItemsSource.NotLoadedYet ()
ObservableItemsSource.ReloadRequired ()
ObservableItemsSource.Remove (System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args)
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

After publishing out the suggested workaround, I am now seeing this exception in App Center: System.IndexOutOfRangeException: IItemsViewSource is empty

Xamarin.Forms.Platform.iOS
EmptySource.GetIndexForItem (System.Object item)
Xamarin.Forms.Platform.iOS
ItemsViewController`1[TItemsView].GetIndexForItem (System.Object item)
Xamarin.Forms.Platform.iOS
SelectableItemsViewController`1[TItemsView].SelectItem (System.Object selectedItem)
Xamarin.Forms.Platform.iOS
SelectableItemsViewController`1[TItemsView].UpdateNativeSelection ()
Xamarin.Forms.Platform.iOS
SelectableItemsViewRenderer`2[TItemsView,TViewController].UpdateNativeSelection ()
Xamarin.Forms.Platform.iOS
SelectableItemsViewRenderer`2[TItemsView,TViewController].UpdateItemsSource ()
Xamarin.Forms.Platform.iOS
ItemsViewRenderer`2[TItemsView,TViewController].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty)
Xamarin.Forms.Platform.iOS
StructuredItemsViewRenderer`2[TItemsView,TViewController].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty)
Xamarin.Forms.Platform.iOS
SelectableItemsViewRenderer`2[TItemsView,TViewController].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty)
Xamarin.Forms.Platform.iOS
GroupableItemsViewRenderer`2[TItemsView,TViewController].OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs changedProperty)
(wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
Xamarin.Forms
BindableObject.OnPropertyChanged (System.String propertyName)
Xamarin.Forms
Element.OnPropertyChanged (System.String propertyName)
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)
Xamarin.Forms
BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
Xamarin.Forms
BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess)
Xamarin.Forms
ItemsView.set_ItemsSource (System.Collections.IEnumerable value)
FieldEdge.Mobile.iOS.CustomRenderers
CustomCollectionViewRenderer.Dispose (System.Boolean disposing)
Foundation
NSObject.Dispose ()
Xamarin.Forms.Platform.iOS
VisualElementPackager.Dispose (System.Boolean disposing)
Xamarin.Forms.Platform.iOS
VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)
Foundation
NSObject.Dispose ()
Xamarin.Forms.Platform.iOS
VisualElementPackager.Dispose (System.Boolean disposing)
Xamarin.Forms.Platform.iOS
VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)
Foundation
NSObject.Dispose ()
Xamarin.Forms.Platform.iOS
VisualElementPackager.Dispose (System.Boolean disposing)
Xamarin.Forms.Platform.iOS
VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)
Foundation
NSObject.Dispose ()
Xamarin.Forms.Platform.iOS
VisualElementPackager.Dispose (System.Boolean disposing)
Xamarin.Forms.Platform.iOS
VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)
Foundation
NSObject.Dispose ()
Xamarin.Forms.Platform.iOS
DisposeHelpers.DisposeModalAndChildRenderers (Xamarin.Forms.Element view)
Xamarin.Forms.Platform.iOS.Platform.Xamarin.Forms
INavigation.PopModalAsync (System.Boolean animated)
Xamarin.Forms
Application+NavigationImpl.OnPopModal (System.Boolean animated)
FieldEdge.Mobile.Shared.MVVMFramework
NavigationService+<>c__DisplayClass8_0.<CloseModal>b__0 ()

Are you removing an item from the collection? If so, then you may have hit another reported issue (which I am also hitting constantly) - https://github.com/xamarin/Xamarin.Forms/issues/9632. If not, then I suppose that, as I said above, the workaround isn't working in all of the cases, unfortunately.

I was able to recreate the last issue I posted. When I navigate to a screen where I have a CollectionView and I modify it by either adding or removing an item, then closing the screen this exception is thrown. If I go to the same screen and don't modify the CollectionView, then exit the screen the exception is not thrown. The workaround is still working for me, though, I did have to refactor some areas because clearing the CollectionView will crash. So, the workaround will definitely introduce new issues. I think the safest bet at this point is not to use CollectionViews.

I have same issue.
Scenario is

  • Create a carouselview
  • Use collectionview inside carouselview template
  • For example click carousel items and collection items; make them states changed - cliecked
  • Try to update some xaml part and check if view updated via hot reload
  • Click carouselview - collectionview items again

At the point, error throws on my experience.

  • It happens on debug mode with ios simulator
  • But i could not reproduce it on the iPhone device deployed with release mode.
  • Error is the case only in debug mode for me.

It would be a lot easier to fix if someone can provide a sample project with the latest Xamarin packages. I can't seem to be able to pinpoint the exact case when this happens constantly. If someone can, please provide a demo project describing the issue so that it can be fixed quickly.

@mduchev Did you see this comment from @daves1992?

https://github.com/xamarin/Xamarin.Forms/issues/8308#issuecomment-672028716

Just asking since it is somewhat buried in the flood of comments. Does it not reproduce the issue for you?

@lafritay Unfortunately, no. I am able to launch the project on both a simulator & device without any issues. Navigating between the pages also doesn't seem to trigger the exception.

@lafritay Unfortunately, no. I am able to launch the project on both a simulator & device without any issues. Navigating between the pages also doesn't seem to trigger the exception.

Which version of IOS?

I managed to replicate it on 12.4.1 but I don't think it replicated on later versions.

It would be a lot easier to fix if someone can provide a sample project with the latest Xamarin packages. I can't seem to be able to pinpoint the exact case when this happens constantly. If someone can, please provide a demo project describing the issue so that it can be fixed quickly.

You have to be on iOS 12 to recreate.

@rd09 Not true. I was seeing the same error on iOS 13 devices and now I'm seeing it again on iOS 14 devices. Unfortunately, the sample projects don't seem to recreate the issue so I suppose that it still persists in some other shape.

@mduchev @rd09 I was able to get a simple repro:

Bugs.zip

Once you load the app, wait for the items to load. Then do the following:

  1. Navigate to the About page using the menu
  2. Navigate back to the items page (it should be blank)
  3. Use "pull to refresh" to refresh the page. The exception should happen when the items finish loading.

The key to making this happen is this line in ItemsPage.xaml.cs

        protected override void OnDisappearing()
        {
            ItemsCollectionView.ItemsSource = null;
            base.OnDisappearing();
        }

The problem is that if CollectionView.ItemsSource is ever updated, the ItemsViewSource that contains the original value never gets disposed. Thus, it retains its CollectionChanged handler and reacts to changes. If the collection then gets updated after navigating away from the page (say, because of a slow network call), the bad ItemsViewSource accesses the disposed ItemsViewController.

I believe the issue is the UpdateItemsSource method in this file: https://github.com/xamarin/Xamarin.Forms/blob/5.0.0/Xamarin.Forms.Platform.iOS/CollectionView/ItemsViewController.cs. It does not dispose of the value held by ItemsSource though it appears it owns the lifetime of the object.

This seems to be confirmed by the fact that it's Android counterpart does dispose of the object (see UpdateItemsSource in this file: https://github.com/xamarin/Xamarin.Forms/blob/79cc0f49fe90a59f02aa0490072b449ccdad4a27/Xamarin.Forms.Platform.Android/CollectionView/ItemsViewAdapter.cs)

And, I think one of the big reasons why this continues to happen is that the workaround that many people are using nulls out the ItemsSource when dispose is called.

@lafritay Im using this workaround which seems to work in short testing. This is not fixing the dispose entirely when the collection source is change correct, but prevents the crashes I had

```
using Example.Controls;
using Example.iOS.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ExtendedCollectionView), typeof(ExtendedCollectionViewRender))]
namespace Example.iOS.Renderers
{
public class ExtendedCollectionViewRender : CollectionViewRenderer
{
protected override GroupableItemsViewController CreateController(GroupableItemsView itemsView, ItemsViewLayout layout)
{
return new CustomGroupableItemsViewController(itemsView, layout);
}
}
}

using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

namespace Example.iOS.Renderers
{
public class CustomGroupableItemsViewController : GroupableItemsViewController
where TItemsView : GroupableItemsView
{
public CustomGroupableItemsViewController(TItemsView selectableItemsView, ItemsViewLayout layout) : base(selectableItemsView, layout)
{
}

    protected override void Dispose(bool disposing)
    {
        base.Dispose(disposing);
        ItemsSource = new EmptySource();
    }
}

}

using System;
using Foundation;
using Xamarin.Forms.Platform.iOS;

namespace Example.iOS.Renderers
{
internal class EmptySource : IItemsViewSource
{
public int GroupCount => 0;

    public int ItemCount => 0;

    public bool Loop { get ; set; }

    public int LoopCount => 0;

    public object this[NSIndexPath indexPath] => throw new IndexOutOfRangeException("IItemsViewSource is empty");

    public int ItemCountInGroup(nint group) => 0;

    public object Group(NSIndexPath indexPath)
    {
        throw new IndexOutOfRangeException("IItemsViewSource is empty");
    }

    public NSIndexPath GetIndexForItem(object item)
    {
        throw new IndexOutOfRangeException("IItemsViewSource is empty");
    }

    public void Dispose()
    {
    }
}

}

@jormenjanssen Here's my full workaround:

using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

namespace myTIPreport.iOS
{
    /// <summary>
    /// Needed because of this bug: https://github.com/xamarin/xamarin.forms/issues/10842. And this bug:
    /// https://github.com/xamarin/Xamarin.Forms/issues/9691
    /// </summary>
    internal sealed class DefaultCollectionItemsViewController : GroupableItemsViewController<GroupableItemsView>
    {
        public DefaultCollectionItemsViewController(GroupableItemsView itemsView, ItemsViewLayout itemsLayout)
            : base(itemsView, itemsLayout)
        {
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Needed because of this bug: https://github.com/xamarin/Xamarin.Forms/issues/9691
            CollectionView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Automatic;
        }

        public override void UpdateItemsSource()
        {
            // Needed because of this bug: https://github.com/xamarin/Xamarin.Forms/issues/8308#issuecomment-710138958
            ItemsSource?.Dispose();
            base.UpdateItemsSource();
        }

        protected override UICollectionViewDelegateFlowLayout CreateDelegator() =>
            new DefaultCollectionItemsViewDelegator(ItemsViewLayout, this);
    }
}
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

namespace myTIPreport.iOS
{
    /// <summary>
    /// Only needed because of this bug: https://github.com/xamarin/xamarin.forms/issues/10842
    /// </summary>
    internal sealed class DefaultCollectionItemsViewDelegator : SelectableItemsViewDelegator<GroupableItemsView, DefaultCollectionItemsViewController>
    {
        public DefaultCollectionItemsViewDelegator(
            ItemsViewLayout itemsLayout,
            DefaultCollectionItemsViewController itemsController)
            : base(itemsLayout, itemsController)
        {
        }

        /// <summary>
        /// Per default this method returns the Estimated size when its not overriden. This method is called
        /// before the rendering process and sizes the cell correctly before it is displayed in the
        /// CollectionView. Calling the base implementation of this method will throw an exception when
        /// overriding the method.
        /// </summary>
        public override CGSize GetSizeForItem(
            UICollectionView collectionView,
            UICollectionViewLayout layout,
            NSIndexPath indexPath)
        {
            // CellForItem() is not reliable here because when the cell at indexPath is not visible it will
            // return null.
            UICollectionViewCell cell = collectionView.CellForItem(indexPath);
            if (cell is ItemsViewCell itemsViewCell)
            {
                // Get the real cell size.
                return itemsViewCell.Measure();
            }
            else
            {
                // This is basically a fallback when CellForItem() returns null.
                return ItemsViewLayout.EstimatedItemSize;
            }
        }
    }
}

using myTIPreport.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(CollectionView), typeof(DefaultCollectionViewRenderer))]

namespace myTIPreport.iOS
{
    /// <summary>
    /// Reasons for this:
    /// 1. This bug: https://github.com/xamarin/xamarin.forms/issues/10842
    /// 2. This bug: https://github.com/xamarin/Xamarin.Forms/issues/8308
    /// </summary>
    internal class DefaultCollectionViewRenderer : GroupableItemsViewRenderer<GroupableItemsView, DefaultCollectionItemsViewController>
    {
        protected override DefaultCollectionItemsViewController CreateController(
            GroupableItemsView itemsView,
            ItemsViewLayout itemsLayout
        ) => new DefaultCollectionItemsViewController(itemsView, itemsLayout);

        protected override void Dispose(bool disposing)
        {
            // Workaround for this bug: https://github.com/xamarin/Xamarin.Forms/issues/8308
            ItemsView.SelectedItem = null;
            ItemsView.ItemsSource = null;

            base.Dispose(disposing);
        }
    }
}

I found a workaround for this bug. I create a custom renderer for Collectionview and I overrode the method Dispose.
Here is the custom renderer code:
[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace Project.iOS.Renderers
{
public class CustomCollectionViewRenderer : CollectionViewRenderer
{
protected override void Dispose(bool disposing)
{
base.ItemsView.SelectedItem = null;
base.ItemsView.ItemsSource = null;
base.Dispose(disposing);
}
}
}

@l0gaw Do I need to implement only CustomRenderer in the iOS project or do I need something else in the main project?

This workaround worked in my case. I did remove also the line "ItemsView.SelectedItem = null" because it is not needed in my case just like what @rd09 said.

same issue happened with me, any solution or workaround ?... this is the stack trace ...
i am using latest stable version from xamarin forms
using AppShell
happens in iOS 12
NSObject.get_SuperHandle ()
UICollectionViewController.get_CollectionView ()
ItemsViewController`1[TItemsView].GetPrototype ()
ItemsViewLayout.DetermineCellSize ()
ListViewLayout.ConstrainTo (CoreGraphics.CGSize size)
ItemsViewLayout.UpdateConstraints (CoreGraphics.CGSize size)
ItemsViewLayout.InvalidateLayout ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate)
UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String[] args)

BugExample.zip

@rmarinho I managed to replicate it by changing the sample slightly.

I added a 100ms delay to setting the Items property.

Iphone 6
IOS 12.4.5
Xamarin.Forms 4.8

This repro no longer crashes as of 4.8.0.1364.

@mduchev @rd09 I was able to get a simple repro:

Bugs.zip

This repro no longer throws the ObjectDisposedException in 5.0.0-pre3.

same issue happened with me, any solution or workaround ?... this is the stack trace ...
i am using latest stable version from xamarin forms

@ahmedroshdy You are seeing this using Xamarin.Forms 4.8.0.1560?

Was this page helpful?
0 / 5 - 0 ratings