SfListView throws ObjectDisposedException when hidden during ItemTapped

Update: I have also posted this as an incident

We have encountered an issue with SfListView on Android.

In our code, we use the ItemTapped event and during this event perform custom navigation to a different control, which causes the SfListView to be removed from its parent layout. This, in turn, causes an ObjectDisposedException:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Syncfusion.ListView.XForms.Android.ListViewItemRenderer'.

I have worked around the issue for now by using await Task.Delay(100); which apparently lets the control's renderer do the thing it has to do before it is removed, but it is clearly not an ideal solution and is clearly quite fragile. The same issue occurs when TappedCommand is used instead.

I have uploaded a simple repo demonstrating the problem to my GitHub and also attached a copy of the solution with this post.

Sample code


private async void ListView_OnItemTapped(object sender, ItemTappedEventArgs e)
{
    //await Task.Delay(100); <-- this dirty hack works around the problem
    Layout.Children.Clear();
}


Attachment: SfListViewTapProblem_9e8b7307.zip

3 Replies

RS Rawoof Sharief Muthuja Sherif Syncfusion Team May 17, 2018 12:14 PM UTC

Hi Martin,  
  
Sorry for the inconvenience.   
   
We have confirmed that the issue with “Object disposed exception occurs when remove the listview from its parent in the ItemTapped event is a defect and logged a defect report for this. It will be included in our 2018 Vol2 SP1 release. We will appreciate your patience until then.         
   
Regards,  
Rawoof M.  




DT David Thompson October 10, 2018 02:51 PM UTC

Hi there, unfortunately this doesn't seem to have been fixed. I get exactly the same error in Android using v16.3.0.21. Martin's hack works for me, but obviously this isn't ideal.

regards

David Thompson


JN Jayaleshwari N Syncfusion Team October 11, 2018 12:07 PM UTC

Hi David,  
 
We have checked the reported issue in our sample and it is working fine. We suspect that the nuget cache is not cleared in your machine. Can you please clear the nuget cache in  you machine and try it.  
 
Please follow the below steps to clear the NuGet cache,

For Windows:

Follow the below link to clear cache,

https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache  

For Mac:

Can you please check and remove in your mac if there is any package in the following location?

• ~/.local/share/NuGet/Cache
• ~/.nuget/package
  
 
   
For your reference we have attached the sample and you can download it from the below link.   
   
   
Please check the reported issue occurs in our sample. If the above sample does not meet your requirement could you please modify the above sample to replicate the issue. Also let us know whether you have used any other framework like Prism, MvvmCross which would highly help us to analyze the query better and provide an appropriate solution.          
   
Regards,   
Jayaleshwari N 


Loader.
Up arrow icon