We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

"Cannot access a disposed object" with multiple DataGrids

Hi,

I am trying to display mutliplate SFDataGrids in one view. I attached a simple example project with the follwing structure:

<ScrollView>
    <LinearLayout>
   
        <SfDataGrid>
        </SfDataGrid>
       
        <SfDataGrid>
        </SfDataGrid>
       
        <SfDataGrid>
        </SfDataGrid>
       
        ...
    </LinearLayout>
</ScrollView>


My question is, if there is a best practise example how to display multiple DataGrids with a specific height in a scrollable view.

Problem 1: every then and now there is "Cannot access a disposed object" - Exception in DataGrid_QueryRowHeight . To reproduce the bug, just scroll some time in different grids and the scrollview.

Image 1

Image 2

Image 3

Problem 2 (petty because scrollviews inside scrollviews are always tricky): Sometimes it is hard to get your grid to scroll instead of the scrollview around

Maybe you can help me with this problems :)

Best regards



Attachment: SFGridTest_c7429085.7z

38 Replies

KK Karthikraja Kalaimani Syncfusion Team January 29, 2020 02:00 PM UTC

Hi Frank,

Thank you for contacting Syncfusion support,

Regarding Expection thrown when scroll on some grid and scrollview

We have checked the issue and we are unable to reproduce the issue in our end and it is working fine as expected in your sample.

Regarding Scrolling issue on grid

We could able to reproduce the issue and currently we validating the and we will validate and update you further details on 31st Jan 2020. We appreciate your patience until then.

Regards,
Karthik Raja
 



FE Frank Effenberger January 30, 2020 12:41 PM UTC

Hi Karthik,
thanks for your response :)

I managed to reproduce the bug for you. The problem is a custom HeaderTemplate.

In the attached project at line 132 I am creating a custom HeaderTemplate. As long as all inflated DataGrids fit into the device screen and there is no need to scroll, it works fine.
For example _gridCount = 1 and _gridCount = 2 works fine, because one or two grids fit into my device screen. (Horizontal screen orientation)

As soon as you need to scroll to view the last grid completely (in my case _gridCount > 2) you will get the System.ObjectDisposedException



Attachment: SFGridTest__Multi_7a85135d.7z


KK Karthikraja Kalaimani Syncfusion Team January 31, 2020 02:19 PM UTC

Hi Frank,

Thank you for the update.

Regarding Scrolling Performance in SfDataGrid.

When we host the SfDataGrid as child inside the ScrollView means we must provide the focus to grid to enable the scrolling, because the touch will move to parent control based on pixels difference.

Regarding Cannot access a disposed object

We have checked your sample and we tried to reproduce the issue, unfortunately we are unable to reproduce the issue in our end and it is working fine as expected.

please let us know the following details,

i) Video of the crash
ii) Device details

Regards,
Karthik Raja



FE Frank Effenberger February 4, 2020 11:38 AM UTC

Hi Karthik,

I edited the project, you can now add GridViews via button and you can also access a log file which logs the exception (should be logged after first crash when reopen the app). Therefore you need grant permission for external storage.
Please let me know if you still can't reproduce the error. I also attached the Exeception log in the .7z.

my Device:
but same problem on my other devices



Attachment: New_test_with_log_2fd6fa0b.7z


KK Karthikraja Kalaimani Syncfusion Team February 5, 2020 02:15 PM UTC

Hi Frank,

Thank you for the update.

We have checked your sample and we could able to reproduce the issue and currently we are validating the reported issue and we will update further details on 7th Feb 2020. We appreciate your patience until then.

Regards,
Karthik Raja



KK Karthikraja Kalaimani Syncfusion Team February 7, 2020 01:50 PM UTC

Hi Frank,

Thank you for your patience.

Still we need more time to find check the issue. So, we will update further details on 11th Feb 2020. We appreciate your patience until then.

Regards,
Karthik Raja
 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 11, 2020 01:26 PM UTC

Hi Frank, 
 
Sorry for the inconvenience. 
 
We have deeply analyzed the reported crash from our side. We have found that the elements inside HeaderTemplate gets disposed before loading the view. We are currently trying to replicate the issue in a simple sample to understand the issue better. We will update you further details on or before 12th February, 2020. We will appreciate your patience until then. 
 
Regards, 
G.Muthu kumaran. 



FE Frank Effenberger February 11, 2020 01:39 PM UTC

Okay, thanks for the effort so far :)



MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 12, 2020 12:58 PM UTC

Hi Frank, 
 
We have deeply analyzed our source and framework to find the root cause of the reported issue. We haven’t disposed off any elements inside HeaderTemplate until view removed from its parent element and also found that no such dispose calls has been identified in our source. So we are analyzing the framework and trying to replicate the issue in a simple sample without SfDataGrid control. However when we have tried to find the call stack of the disposal for the LinearLayout element inside the HeaderTemplate, we have found that the exception is not thrown. We have used the custom LinearLayout and set it to HeaderTemplate as below. 
 
 
 
Please let us know whether the provided workaround resolves the reported issue at your end. 
 
Regards, 
G.Muthu kumaran. 



FE Frank Effenberger February 13, 2020 07:17 AM UTC

Hi,
unfortunatley your workaround does not work. It works a littel bit better, means, sometimes I am able to inflate more grid views, but it still crashes permanently.

I used public class HeaderLinearLayout(Context context) : base(context) as you mentioned as workaround and override the Dispose-function.

In the link you can download 2 Videos:
1. video shows crash after clicking the Add-button only once with DisposedObjectError.
2. video shows some performance and scrolling problems after adding 4-5 grids followed by a crash with a NullReferenceException. In this video you see how hard it is to get the grid itself to scroll. After you accessed a grid with scrolling you can notice serious performance leaks and the more you scroll, the worser it gets.

Download videos here

Thanks for your effort but I still can't work with that





MK Muthu Kumaran Gnanavinayagam Syncfusion Team February 17, 2020 02:26 AM UTC

Hi Frank, 
 
We have referred the attached video and replicated all the reported issues from our side and would like to let you know that the reported crashes is due to garbage collection in android framework issue and not disposal from our control. Since in Android platform, Android Mono Framework collects the minor garbage whenever the live objects count in the current application exceeds a threshold which causes the application crash which is unavoidable in the android development. Thus the only way to resolve the minor garbage collection is to reduce the live object count which is currently not possible for a component like SfDataGrid. Because we cannot find the current live objects count from android framework inside our components as they will be maintained in the internal android framework for garbage collection. Android has provided no options to track the live objects count in mono/android framework inside a library. The GC will be collect automatically when it reaches the maximum threshold by the Android only and this is actual architecture of the framework. You can refer the below link for more information,  
 
 
Regards, 
G.Muthu kumaran.  



FE Frank Effenberger February 28, 2020 06:23 AM UTC

Sorry for the late response,

so you are telling me, there is no way to have multiple DataGrids with HeaderTemplates in a scrollable view?

Since the app crashes sometimes with only 1 or 2 grids, i am not satisfied with the answer that 1 datagrid with headertemplate should exceed the live objects treshold, while I am able to infalte for example 20 recycler views with 3000 elments each in my scrollview and it works fine.

We need to find a solution for that, since DataGrids is one of the main reason for buying the Xamarin license.

Best regards


SS Sivaraman Sivagurunathan Syncfusion Team March 2, 2020 01:33 PM UTC

Hi Frank,  
  
Sorry for the inconvenience.  
  
Currently we are validate the reported issue from our side. We will update you further details on or before  5th March, 2020. We will appreciate your patience until then.  
  
Regards,  
Sivaraman S 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 6, 2020 12:41 PM UTC

Hi Frank, 
 
We are still trying to retain the native templated elements from disposing at our end. We will update further details on or before March 10th, 2020. 
 
Regards, 
G.Muthu kumaran. 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 10, 2020 02:07 PM UTC

Hi Frank,  
  
We are still trying to retain the native templated elements from disposing at our end. We will update further details on or before March 12th, 2020.  
  
Regards,  
G.Muthu kumaran. 
 



MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 12, 2020 01:57 PM UTC

Hi Frank,   
   
We are still trying to retain the native templated elements from disposing at our end. We will update further details on or before March 16th, 2020.   
   
Regards,   
G.Muthu kumaran.  



FE Frank Effenberger March 13, 2020 07:56 AM UTC

Alright, hopefully we'll see some results next week.
Thanks for the effort.

Regards


MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 16, 2020 01:51 PM UTC

Hi Frank, 
 
Sorry for the delay. 
 
We have deeply analyzed the cause of the crash from our side. We have also checked for possible native object disposal at our end and we are glad to let you know that we have successfully found a way to retain the native objects from disposing at our end. So we have finalized to confirm this as a bug at our end. We will provide fix for this issue “Object disposed exception when adding more DataGrid at runtime in LinearLayout” on or before March 30th, 2020. We will appreciate your patience until then. 
 
Regards, 
G.Muthu kumaran. 



FE Frank Effenberger March 17, 2020 08:16 AM UTC

Alright, I'm glad there will be a Bugfix :)
Thanks for the effort


MK Muthu Kumaran Gnanavinayagam Syncfusion Team March 17, 2020 10:42 AM UTC

Hi Frank, 
 
Thanks for the update. We will let you know once the issue has been fixed. 
 
Regards, 
G.Muthu kumaran. 



KK Karthikraja Kalaimani Syncfusion Team March 31, 2020 11:55 AM UTC

Hi Frank,

Due to complexity, we unable to fix the issue. We are working on this with high priority and we need some more time to work on this. We will fix this issue and include the issue fix in our next weekly NuGet release which is schedule on 7th April 2020. 
Regards, 
Karthik Raja


FE Frank Effenberger April 2, 2020 05:39 AM UTC

I hope that the fix was pushed forward the last time and I can rely on you. I need the fix and will look for alternatives if no solution is found here.

Best regards


KK Karthikraja Kalaimani Syncfusion Team April 3, 2020 12:14 PM UTC

Hi Frank, 
  
As we promised earlier, we have to check the null possibilities for all the views in our source. So, will provide the further details on 7th April 2020.  
  
We appreciate your patience until then. 

Regards, 
Karthik Raja


KK Karthikraja Kalaimani Syncfusion Team April 7, 2020 01:10 PM UTC

Hi Frank,

We glad to tell that we have fixed the reported issue and currently we could not able to include the fix in our weekly nuget. So, we will include the fix in our upcoming weekly nuget which is scheduled on 14th April 2020.

We appreciate your patience until then.

Regards,
Karthik Raja




KK Karthikraja Kalaimani Syncfusion Team April 14, 2020 06:19 AM UTC

Hi Frank,

Due to network problem from our side, the fix was not included in our weekly nuget release. So, we will include the fix in our upcoming weekly nuget which is scheduled on 21st April 2020. However, if you may want the fix earlier than 21st April, please revert us with your version number so that we can provide patch in your version.

Regards,
Karthik Raja 



FE Frank Effenberger April 15, 2020 07:05 AM UTC

I just updated to the latest stable nuget version 18.1.0.44 of Xamarin.SfDataGrid.Android

I expect, that you fix this bug in my version, since the bugfixes regarding to this bug are expected to be fixed by the costumers of my application.
It's been a month since you confirmed this as a bug at your end.

Best regards


KK Karthikraja Kalaimani Syncfusion Team April 16, 2020 07:24 AM UTC

Hi Frank,

We have included the fix and generated the custom assemblies with SfDataGrid version 18.1.0.44.
. Please find the custom assemblies by the following link, 
   
Custom Assemblies Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Dll-87721105.zip

Installation Direction:  
These assemblies should replace the existing assemblies in the following location.    
 
      
{Syncfusion Installed location}\Essential Studio\18.1.0.44\Xamarin\lib\ android\ Syncfusion.SfNumericTextBox.Android.dll  
{Syncfusion Installed location}\Essential Studio\18.1.0.44\Xamarin\lib\ android\ Syncfusion.GridCommon.Android.dll  
{Syncfusion Installed location}\Essential Studio\18.1.0.44\Xamarin\lib\ android\ Syncfusion.Linq.Android.dll      
{Syncfusion Installed location}\Essential Studio\18.1.0.44\Xamarin\lib\ android\ Syncfusion.SfDataGrid.Android.dll       


Regards,
Karthik Raja 



FE Frank Effenberger April 16, 2020 08:23 AM UTC

Thanks for the update.

But the fix will still be in the update 18.1.0.45 on 21st April next week, right? Since for my tfs-controlled solution its much easier to just work with the nuget-updates.

Best regards


KK Karthikraja Kalaimani Syncfusion Team April 17, 2020 06:35 AM UTC


Hi Frank,

Thank you for the update.

We will include this fix in our next upcoming weekly NuGet update which is expected to available by April 21, 2020.

Regards,
Karthik Raja  



KK Karthikraja Kalaimani Syncfusion Team April 21, 2020 07:23 AM UTC

Hi Frank, 
  
We are glad to let you know that we have included the fix in our weekly NuGet update version 18.1.0.45 which is available for download (nuget.org).  
  
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance. 
  
Regards, 
Karthik Raja 



FE Frank Effenberger April 22, 2020 12:54 PM UTC

IT STILL DOES NOT WORK !!! :-/

Example 1: (see attachement "log file sample projekt.txt" and scroll down (old and new error logs are included))
For simpler reproduction just open my attached sample project from my answer on 4th. February and add "_gridCount = 10;" after line 76 (after "_contentLayout.AddView(addGrid);"). So that on start or everytime you click the button, the layout is cleaned up and 10 new grids are inflated.
Sometimes on the first click, sometimes on the second, third etc. you will notice the app will crash

Example 2: (see attachement "log file my app", it is the log of my application I am working with)
Context: I have list of items. Those items have all data for a grid.
Usage:

foreach(var item in items)
{
     _contentLayout.AddView(CreateSFGrid(item))
}

It crashes everytime!

If I use
  _contentLayout.AddView(CreateSFGrid(items[0]))
or
  _contentLayout.AddView(CreateSFGrid(items[1]))
or
  _contentLayout.AddView(CreateSFGrid(items[2]))
or
....

it works and a single grid is displayed. So there can't be a problem with the data in my items, since a single item of those can be displayed

Please let me know, when you reproduced Example1.
I am trying to create a sample project for Example2.

This was a very disappointing bugfix (actually it was no fix)

EDIT:
After uninstalling the SFGridTest app (first installation was before nuget update) and have a clean new install of the test app, it is much harder to reprocue the bug (just every 10th times i open the app and after clicking the button at least 10 times the app crashes).

Example 2 still occurs even after clean new install



Attachment: exceptions_ffd13ee7.7z


FE Frank Effenberger April 23, 2020 10:17 AM UTC

Alright, i managed to create Sample Project for you.

While evalutating the bugs and reduced the complexity of my grids to a minimum (no custom cells, no header templates), there occurs always a crash


My usecase (simplified in the attached project):
- My Activity has a FrameLayout and inflates different Fragments (in this test case just one fragment "MainFragment").
- MainFragment also has a FrameLayout and Inflates different Fragments via Click on the Tab Buttons)

Just deploy the App, and switch between OverviewFragment and GridFragement until the Error occurs. Sometimes it occurs on the first time clicking on "Grid Tab", sometimes on 10th time. But it will crash.

Note: grid.AllowPullToRefresh = false does not sovle this problem

Note 2: If have no idea, if this error is the source of the object reference error in the createColumn method which occured before (see log file on my post before). I think this must be evaluted step by step. At the moment this is the simplest kind of grid you can create.

I realy hope we can get it going!


Attachment: SFGridTest_ffb1de1a.7z


KK Karthikraja Kalaimani Syncfusion Team April 23, 2020 01:43 PM UTC

Hi Frank,

Regarding “Cannot access a disposed object name :ObjectName:Syncfusion.SfDataGrid.SfPullToRefreshView”
 
This is already known framework issue and we have reported to Xamarin.Android team. Right now they provided an workaround to overcome this issue. So please follow the below.

 Add new text file which contains the line
MONO_GC_PARAMS=bridge-implementation=old, and then setting the build action of the file to AndroidEnvironment.

Report link :
https://github.com/xamarin/xamarin-android/issues/3905

Regarding “System.ObjectDisposedException: Cannot access a disposed object.Object name: 'Android.Widget.LinearLayout'

We could able to reproduce the issue. Currently, we are validating the reported issue and we will update you further details on or before 27th April 2020.

We appreciate your patience until then.

Regards,
Karthik Raja
 



FE Frank Effenberger April 23, 2020 02:06 PM UTC

Thanks for your answer.

I will try the workaround.

Regarding “System.ObjectDisposedException: Cannot access a disposed object.Object name: 'Android.Widget.LinearLayout'
- I just saw, that I attached an old log file in my post from April 22. The logfile with this error is from 04.02.2020. Thats before the update. So, where did you reproduced this issue in the new attached project from today?


FP Farjana Parveen Ayubb Syncfusion Team April 25, 2020 10:54 AM UTC

Hi Frank,

This is Farjana Parveen from Syncfusion. How are you? I'm a Senior Support Manager here. To continuously assist you, this case was endorsed under my supervision. I literally just got your case and I've just fully reviewed the matter at hand and all correspondence related. My sincere apologies for the delay in getting back to you. 

We know that this is not the outcome you were hoping for, and we as a team strive continuously to provide the best possible customer experience and avoid any scope 
Of bitter experiences

The case about the issue being repeated is indeed disheartening and unfortunate to have missed out in spite of our rigorous testing enviornment. I understand you desire to get this solved ASAP.  Please know that I'd like to offer you my entire support as i will be working on this personally and closely along with development team and provide the solution in a timely manner.

We have already began works on this and I can reassure you that this is currently been worked with the highest priority. You can expect to hear from us on or before 28th April.
 
 
Regards, 
Farjana Parveen A 
 



FE Frank Effenberger April 27, 2020 05:59 AM UTC

Hi Farjana,
thank you for your answer and for taking care of my problem.

The workaround for the SfPullToRefreshView exception works.

Currently I am able to inflate multiple simple grids in my view.
Next, I am increasing the complexity of my grids step by step and let you if I run into problems.

Best regards


FE Frank Effenberger April 27, 2020 10:02 AM UTC

Good news :)

I was able to inflate multiple grids with my required complextiy. I will do some testing later with the custom RowHeight calculation, but so far it looks good!

Thanks for the effort.


KK Karthikraja Kalaimani Syncfusion Team April 28, 2020 09:45 AM UTC

Hi Frank,

We have created a new incident under your Direct trac account to follow up with this query “Exception Thrown when creating multiple DataGrid”. We suggest you to follow up with the incident for further updates. Please log in using the below link. 

 

Regards,
Karthik Raja 


Loader.
Up arrow icon