This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 45330 - System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Views.GestureDetector'.
Summary: System.ObjectDisposedException: Cannot access a disposed object. Object name:...
Status: IN_PROGRESS
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.2
Hardware: PC Windows
: Highest blocker
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-12 16:58 UTC by bblonchek
Modified: 2017-09-23 07:56 UTC (History)
40 users (show)

See Also:
Tags: Android ac fr
Is this bug a regression?: ---
Last known good build:


Attachments
sample solution (196.51 KB, application/x-zip-compressed)
2016-10-12 17:05 UTC, bblonchek
Details
Nullreference exception on IVisulaelement platforms property (30.58 KB, image/png)
2017-08-29 10:43 UTC, Paul Anderson
Details
TableView Test (247.75 KB, application/x-zip-compressed)
2017-09-20 22:15 UTC, Samantha Houts
Details
TableView/HybridWebView Test (254.41 KB, application/x-zip-compressed)
2017-09-20 22:47 UTC, Samantha Houts
Details

Description bblonchek 2016-10-12 16:58:50 UTC
# Steps to reproduce
See the attached sample solution.
Run the app.
Scroll back and forth in the list rapidly.
Tap on an item to go to a detail page
Navigate back to the list page.
Scroll back and forth in the list.

Eventually the app will crash with the following exception:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Views.GestureDetector'.

10-12 12:48:04.970 I/MonoDroid(31095): UNHANDLED EXCEPTION:
10-12 12:48:04.986 I/MonoDroid(31095): System.ObjectDisposedException: Cannot access a disposed object.
10-12 12:48:04.986 I/MonoDroid(31095): Object name: 'Android.Views.GestureDetector'.
10-12 12:48:04.986 I/MonoDroid(31095):   at (wrapper managed-to-native) Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_boolean_method_a (intptr,intptr&,intptr,intptr,intptr,Java.Interop.JniArgumentValue*)
10-12 12:48:04.986 I/MonoDroid(31095):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008f] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11728 
10-12 12:48:04.986 I/MonoDroid(31095):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0006b] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:67 
10-12 12:48:04.986 I/MonoDroid(31095):   at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e) [0x0002c] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:12433 
10-12 12:48:04.986 I/MonoDroid(31095):   at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00035] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:32 
10-12 12:48:04.987 I/MonoDroid(31095):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:12420 
10-12 12:48:04.987 I/MonoDroid(31095):   at (wrapper dynamic-method) System.Object:97380020-8a25-41e1-9c74-c813eb723b61 (intptr,intptr,intptr)
10-12 12:48:05.028 E/mono-rt (31095): Stacktrace:
10-12 12:48:05.028 E/mono-rt (31095): 
10-12 12:48:05.028 E/mono-rt (31095):   at <unknown> <0xffffffff>
10-12 12:48:05.028 E/mono-rt (31095):   at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_new_string (intptr,intptr&,char*,int) <0x00047>
10-12 12:48:05.028 E/mono-rt (31095):   at Java.Interop.JniEnvironment/Strings.NewString (char*,int) [0x0000a] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:13019
10-12 12:48:05.028 E/mono-rt (31095):   at Java.Interop.JniEnvironment/Strings.NewString (string) [0x00028] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.Strings.cs:15
10-12 12:48:05.028 E/mono-rt (31095):   at Android.Runtime.JNIEnv.NewString (string) [0x0000c] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Android.Runtime/JNIEnv.cs:937
10-12 12:48:05.028 E/mono-rt (31095):   at Java.Lang.Throwable..ctor (string) [0x00022] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Java.Lang.Throwable.cs:47
10-12 12:48:05.028 E/mono-rt (31095):   at Android.Runtime.JavaProxyThrowable..ctor (System.Exception) [0x00000] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Android.Runtime/JavaProxyThrowable.cs:10
10-12 12:48:05.028 E/mono-rt (31095):   at Java.Lang.Throwable.FromException (System.Exception) [0x00023] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Java.Lang/Throwable.cs:241
10-12 12:48:05.028 E/mono-rt (31095):   at Android.Runtime.AndroidEnvironment.UnhandledException (System.Exception) [0x0007e] in /Users/builder/data/lanes/3819/c1d1c79c/source/xamarin-android/src/Mono.Android/Android.Runtime/AndroidEnvironment.cs:116
10-12 12:48:05.028 E/mono-rt (31095):   at (wrapper dynamic-method) object.97380020-8a25-41e1-9c74-c813eb723b61 (intptr,intptr,intptr) <IL 0x00030, 0x0009f>
10-12 12:48:05.028 E/mono-rt (31095):   at (wrapper native-to-managed) object.97380020-8a25-41e1-9c74-c813eb723b61 (intptr,intptr,intptr) <IL 0x00023, 0x000ff>


# Expected behavior


# Actual behavior


# Supplemental info (logs, images, videos)
Have to continue to scroll in list, tap on items, repeat to get the crash as this is an intermittent issue.
The sample is using a third-party syncfusion chart control to put the image in the list cell as this seems to be related to having images in listview items and that is what is causing the problem in our solution.

# Test environment (full version information)





Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-40000-00000-AA974
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-40000-00000-AA974
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA974
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA974
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA974
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   7.8.00927.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015 (RC1 Update 1)   14.1.20203.0
ASP.NET and Web Tools 2015 (RC1 Update 1)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Azure App Service Tools v2.9.1   14.0.20519.0
Azure App Service Tools v2.9.1

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.0.6000.0
Microsoft Azure Data Lake Tools for Visual Studio

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft Azure HDInsight HQL Service   2.0.6000.0
Language service for Hive query

Microsoft Azure HDInsight Tools for Visual Studio   2.0.6000.0
An integrated development environment for HDInsight application development.

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.9.40518.2

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Visual Studio Tools for Universal Windows Apps   14.0.25527.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.2.0.695 (7603786)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.1.2 (c1d1c79)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.0.0.1 (29910bb)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 bblonchek 2016-10-12 17:05:29 UTC
Created attachment 18003 [details]
sample solution
Comment 2 Rob Wilson 2016-10-13 12:57:45 UTC
Thank you for raising this ticket! 

I can confirm that I have the exact same issue, re-created in exactly the same way, however I use FFImageLoading to render my images.  The current commonality is that images are involved within the list.

I have no caching strategy set in my XAML.

Some history behind my issue is on the Xamarin Forums http://forums.xamarin.com/discussion/comment/226024/#Comment_226024
Comment 3 Attila Fodor 2016-10-19 06:45:18 UTC
I have the same problem.

I/MonoDroid( 7548): UNHANDLED EXCEPTION:

I/MonoDroid( 7548): System.ObjectDisposedException: Cannot access a disposed object.

I/MonoDroid( 7548): Object name: 'Android.Views.GestureDetector'.

I/MonoDroid( 7548):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x00036] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0004a] in <d572ae0ccf89437fad1de1370c623a06>:0 

I/MonoDroid( 7548):   at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at (wrapper dynamic-method) System.Object:5da60e97-7d76-4239-a0be-a819cd94b0a1 (intptr,intptr,intptr,intptr)

I/MonoDroid( 7548): UNHANDLED EXCEPTION:

I/MonoDroid( 7548): System.ObjectDisposedException: Cannot access a disposed object.

I/MonoDroid( 7548): Object name: 'Android.Views.GestureDetector'.

I/MonoDroid( 7548):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x00036] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0004a] in <d572ae0ccf89437fad1de1370c623a06>:0 

I/MonoDroid( 7548):   at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at (wrapper dynamic-method) System.Object:5da60e97-7d76-4239-a0be-a819cd94b0a1 (intptr,intptr,intptr,intptr)

I/MonoDroid( 7548): --- End of stack trace from previous location where exception was thrown ---

I/MonoDroid( 7548):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <98ccc6281ed94c8ba27ba961e361bf36>:0 

I/MonoDroid( 7548):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a8] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

I/MonoDroid( 7548):   at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00036] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00035] in <d572ae0ccf89437fad1de1370c623a06>:0 

I/MonoDroid( 7548):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

I/MonoDroid( 7548):   at (wrapper dynamic-method) System.Object:54198da8-b646-4e28-936a-2427337aa68f (intptr,intptr,intptr)

E/InputEventReceiver( 7548): Exception dispatching input event.

E/MessageQueue-JNI( 7548): Exception in MessageQueue callback: handleReceiveCallback

E/MessageQueue-JNI( 7548): android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.

E/MessageQueue-JNI( 7548): Object name: 'Android.Views.GestureDetector'.

E/MessageQueue-JNI( 7548):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

E/MessageQueue-JNI( 7548):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00001] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

E/MessageQueue-JNI( 7548):   at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x00036] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

E/MessageQueue-JNI( 7548):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0004a] in <d572ae0ccf89437fad1de1370c623a06>:0 

E/MessageQueue-JNI( 7548):   at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

E/MessageQueue-JNI( 7548):   at (wrapper dynamic-method) System.Object:5da60e97-7d76-4239-a0be-a819cd94b0a1 (intptr,intptr,intptr,intptr)

E/MessageQueue-JNI( 7548): --- End of stack trace from previous location where exception was thrown ---

E/MessageQueue-JNI( 7548):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <98ccc6281ed94c8ba27ba961e361bf36>:0 

E/MessageQueue-JNI( 7548):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a8] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

E/MessageQueue-JNI( 7548):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00068] in <a8bda6a3637a4dffb7ce4066ce3b1247>:0 

E/MessageQueue-JNI( 7548):   at Android.Views.View.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00036] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

E/MessageQueue-JNI( 7548):   at Xamarin.Forms.Platform.Android.PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00035] in <d572ae0ccf89437fad1de1370c623a06>:0 

E/MessageQueue-JNI( 7548):   at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in <d2860ab0a43a41a5a70ae07f69495af1>:0 

E/MessageQueue-JNI( 7548):   at (wrapper dynamic-method) System.Object:54198da8-b646-4e28-936a-2427337aa68f (intptr,intptr,intptr)

E/MessageQueue-JNI( 7548): 	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_dispatchTouchEvent(Native Method)

E/MessageQueue-JNI( 7548): 	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:47)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)

E/MessageQueue-JNI( 7548): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)

E/MessageQueue-JNI( 7548): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)

E/MessageQueue-JNI( 7548): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)

E/MessageQueue-JNI( 7548): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2464)

E/MessageQueue-JNI( 7548): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)

E/MessageQueue-JNI( 7548): 	at android.view.View.dispatchPointerEvent(View.java:7886)

E/MessageQueue-JNI( 7548): 	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3947)

E/MessageQueue-JNI( 7548): 	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3826)

E/MessageQueue-JNI( 7548): 	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3392)

E/MessageQueue-JNI( 7548): 	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3442)

E/MessageQueue-JNI( 7548): 	at

D/AndroidRuntime( 7548): Shutting down VM

Here is my environment

Microsoft Visual Studio Professional 2015
Version 14.0.25421.03 Update 3
Microsoft .NET Framework
Version 4.6.01038

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-40000-00000-AA083
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-40000-00000-AA083
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA083
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA083
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-40000-00000-AA083
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   7.9.01018.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11107.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Clang with Microsoft CodeGen   14.0.25317
Clang with Microsoft CodeGen

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Devart Code Compare   4.1.78
Devart Code Compare
Copyright (c) 2012-2015 Devart. All rights reserved.
http://www.devart.com/codecompare/

Devart dotConnect for Oracle   8.5.521.0
Devart dotConnect for Oracle
Copyright 2002 - 2015 Devart. All rights reserved.
Web: www.devart.com/dotconnect/oracle
Support: support@devart.com

Devart Entity Developer   5.8.720.0
Devart Entity Developer
Copyright © 2008-2015 Devart. All rights reserved.
Web: www.devart.com/entitydeveloper 
Support: support@devart.com

EMDKProfileManagerWizardVS   1.0
EMDK for Xamarin

GitHub.VisualStudio   1.0
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript   1.8.34.0
TypeScript tools for Visual Studio

Visual C++ for Cross Platform Mobile Development (Android)   14.0.25401.00
Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Cross Platform Mobile Development (iOS)   14.0.25401.00
Visual C++ for Cross Platform Mobile Development (iOS)

Visual Studio Tools for Apache Cordova   Update 10
Visual Studio Tools for Apache Cordova

Visual Studio Tools for Universal Windows Apps   14.0.25420.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Windows Installer XML Toolset   3.10.3.3007
Windows Installer XML Toolset version 3.10.3.3007
Copyright (c) .NET Foundation and contributors. All rights reserved.

Xamarin   4.2.0.695 (7603786)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.1.2 (c1d1c79)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.0.0.1 (29910bb)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 4 Perry Hickman 2016-10-19 12:34:03 UTC
I'm getting the same problem except the lists I use only has text.

In the view down the page I have several lines and each line a has a prompt and a entry.  If the user clicks in the entry I bring up a popup with an entry and a list of possible choices (as many as 100 item could be in the list). The user could either type or scroll through the list. The list is updated on every change to the entry.  Only four items in the list are seen at a time so the user needs to scroll the list.

If I go quickly from one line to the other clicking in the entry, (popup comes up) scrolling to the end of the list choose an item.  (popup goes down) Go to the next line and do the same thing. After going through a few lines of doing this the app will crash with the "Cannot access a disposed object. 'Android.Views.GestureDetector'" error.

Package Manager Console Host Version 3.4.0.798

Xamarin   4.2.0.680 (c4382f5)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.0.18 (0e59c36)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.0.0.6 (6c3fee4)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 5 xevilboss 2016-10-19 14:00:49 UTC
I have same problem. Android 6.0, Xamarin Forms 2.3.3.152
Comment 6 Pawel Kanarek 2016-10-24 08:58:01 UTC
The same problem. Xamarin.Android 7.0.1.3, Xamarin.Forms 2.3.1.114
Comment 7 h.van.triest 2016-11-03 11:21:36 UTC
The same problem. Xamarin.Android 7.0.1.6, Xamarin.Forms 2.3.2.127
Comment 8 adrianknight89 2016-11-20 20:59:36 UTC
I think one requires a license to use SfChart. Any way someone can attach another repro without this library?
Comment 9 Robert Ewen 2016-11-23 20:37:23 UTC
The same problem. Xamarin.Android 7.0.2.37, Xamarin.Forms 2.3.3.168
Comment 10 bizzare 2016-11-28 11:59:51 UTC
Similar problem. Android 6 , Xamarin.Forms 2.3.0.107

For the listview, I have a boxview, multiple labels and 2 buttons per viewcell.

11-28 19:40:53.311 I/MonoDroid(15284): UNHANDLED EXCEPTION:
11-28 19:40:53.311 I/MonoDroid(15284): System.ObjectDisposedException: Cannot access a disposed object.
11-28 19:40:53.311 I/MonoDroid(15284): Object name: 'Android.Views.GestureDetector'.
11-28 19:40:53.311 I/MonoDroid(15284):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00030] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.cs:153 
11-28 19:40:53.311 I/MonoDroid(15284):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00002] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:57 
11-28 19:40:53.311 I/MonoDroid(15284):   at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x0002c] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.GestureDetector.cs:1546 
11-28 19:40:53.311 I/MonoDroid(15284):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0003f] in C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:101 
11-28 19:40:53.311 I/MonoDroid(15284):   at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00019] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:3558 
11-28 19:40:53.311 I/MonoDroid(15284):   at (wrapper dynamic-method) System.Object:5a6afa60-859d-4d0a-995b-1031273ea7e2 (intptr,intptr,intptr,intptr)
11-28 19:40:53.341 W/art     (15284): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
11-28 19:40:53.351 D/Mono    (15284): DllImport searching in: '__Internal' ('(null)').
11-28 19:40:53.351 D/Mono    (15284): Searching for 'java_interop_jnienv_throw'.
11-28 19:40:53.351 D/Mono    (15284): Probing 'java_interop_jnienv_throw'.
11-28 19:40:53.351 D/Mono    (15284): Found as 'java_interop_jnienv_throw'.
Unhandled Exception:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Views.GestureDetector'.
Comment 11 Rui Marinho 2017-01-24 11:54:38 UTC
Should be fixed in 2.3.5-pre1
Comment 12 Fokke Vermeulen 2017-01-24 12:48:47 UTC
@Rui Marinho
Does a workaround help for us while waiting for that release?

Why not a hot-fix?
Comment 13 Pete Schmitz 2017-02-08 22:10:56 UTC
Any ETA on the 2.3.5 pre-release?
Comment 14 alperen babagil 2017-02-17 13:10:28 UTC
Same error Xamarin forms v2.3.3.180
Comment 15 williamd 2017-02-24 15:21:04 UTC
This is a crashing issue. Can we get a stable release with this fix please?
Comment 16 Attila Fodor 2017-02-24 15:24:24 UTC
I agree with William.
This is a serious problem.
Comment 17 Attila Fodor 2017-02-24 15:24:43 UTC
I agree with William.
This is a serious problem.
Comment 18 Nikolai Doronin 2017-02-28 08:00:06 UTC
I noticed that new version of Xamarin.Forms was released a few days ago; release notes say it comprises a fix for this issue: https://github.com/xamarin/Xamarin.Forms/releases/tag/release-2.3.3-hf1

But unfortunately, it seems this version is not available via NuGet: https://www.nuget.org/packages/Xamarin.Forms/
Comment 19 williamd 2017-02-28 13:53:31 UTC
I was able to put the nupkg files in my local nuget feed and I can confirm that the problem is fixed in the hotfix.
Comment 20 Pete Schmitz 2017-03-06 18:04:07 UTC
Can we get a nuget release that includes hf1 please? 

https://www.nuget.org/packages/Xamarin.Forms/
Comment 21 Adam 2017-03-07 04:13:34 UTC
Pete if you want a version based off the current master, which seems to be 2.3.4-pre1, with this hotfix, and I removed Windows 8 support, you can use my public feed (https://www.myget.org/F/adpedley/api/v3/index.json) for a package in the meantime.

I also commented on https://github.com/xamarin/Xamarin.Forms/commit/fa12ae1bae967b75f49d0e2643524c45c6a788ed where the fix was committed. I don't believe it has been properly fixed, there is still a small chance it will re-occur and it wasn't fixed in the framerenderer.cs either. There may also be other places.
Comment 22 Pete Schmitz 2017-03-07 17:54:29 UTC
Adam, thanks for taking the time to prepare a package that includes the hotfix. 

However, we're desperate for a stable, official, fix to this problem - it's a bottleneck that's preventing us from patching another issue that a few of our users are encountering in our current release build (https://bugzilla.xamarin.com/show_bug.cgi?id=40486).

For our app, we found that this bug is much more problematic, which forced us to revert our forms package. I feel the severity of this "RESOLVED FIXED" issue is being undermined...
Comment 23 E.Z. Hart 2017-03-07 21:31:57 UTC
Reopening this, as Adam pointed out above this issue is not fixed in FrameRenderer.
Comment 24 Matthew Richardson 2017-03-14 11:51:52 UTC
OK, looks like it also affects PlatformRenderer too.
Was looking through crash analytics on VS Mobile Centre today for our beta, and found 15 crashes with ObjectDisposedException. Stacktrace pointed to PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) 06b59d59292941ee812f7dbf5408f80c:0.

So in summary...

RESOLVED
VisualElementRenderer.cs

NEEDS FIX
PlatformRenderer.cs
FrameRenderer.cs (TBC)

Note: As a workaround, we found switching Mono GC bridge mode from Tarjan to New worked. Seems Tarjan is a little more aggressive. Not sure if this problem should be reported to the Android platform team?

However defensive coding in the base renderer should prevent the crash.
Comment 25 Britton Beckham 2017-03-15 02:46:41 UTC
It looks like everyone has said enough about this issue, but wanted to let you guys know it's happening for me as well using 2.3.4.212-pre4. Wanted to add my stack trace in case there is some other file you guys over looked. We are eagerly awaiting a fix.... sucks we have to wait for 2.3.5.


JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
Cannot access a disposed object. Object name: 'Android.Views.GestureDetector'.

Cannot access a disposed object. Object name: 'Android.Views.GestureDetector'.
1
JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) a043032cf94a485190047a14918b9f60:0
2
JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) a043032cf94a485190047a14918b9f60:0
3
GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) 6dcfb9cbdc674d6e80e25233e0b558fb:0
4
IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) c446677c81524a0dbb8a7609a30be752:0
5
View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) 6dcfb9cbdc674d6e80e25233e0b558fb:0
6
(wrapper dynamic-method) System.Object:b16b3bc0-ddcb-4a51-9f84-6771f35641b9 (intptr,intptr,intptr,intptr)
7
ExceptionDispatchInfo.Throw () 8c304e4006094a46a7950338a3b3cb5d:0
8
JniEnvironment+InstanceMethods.CallNonvirtualBooleanMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) a043032cf94a485190047a14918b9f60:0
9
JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) a043032cf94a485190047a14918b9f60:0
10
View.DispatchTouchEvent (Android.Views.MotionEvent e) 6dcfb9cbdc674d6e80e25233e0b558fb:0
11
PlatformRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) c446677c81524a0dbb8a7609a30be752:0
12
View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) 6dcfb9cbdc674d6e80e25233e0b558fb:0
13
(wrapper dynamic-method) System.Object:3b610b57-cc98-440d-aeb4-cf5ec08d9a07 (intptr,intptr,intptr)
Comment 26 Rui Marinho 2017-03-22 11:56:19 UTC
Should be fixed on 2.3.4-pre6
Comment 27 MG 2017-05-26 16:31:07 UTC
Hey,
I'm on 2.3.4.247 and I'm facing this issue now, cannot attach the project as it's our production project.

Any thoughts?
Comment 28 MG 2017-05-26 17:15:20 UTC
A full stack trace here:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FormsTextView'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <5716a943049b49ca928a3a1c8d2386f4>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <5716a943049b49ca928a3a1c8d2386f4>:0 
  at Android.Widget.TextView.set_TextFormatted (Java.Lang.ICharSequence value) [0x00029] in <20a5debecbfd420ba8345429bf71acbe>:0 
  at Android.Widget.TextView.set_Text (System.String value) [0x0000d] in <20a5debecbfd420ba8345429bf71acbe>:0 
  at Xamarin.Forms.Platform.Android.LabelRenderer.UpdateText () [0x00098] in <fb1b373bb41f422cab210b1850374a59>:0 
  at Xamarin.Forms.Platform.Android.LabelRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x000c5] in <fb1b373bb41f422cab210b1850374a59>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000fb] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0014b] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in <42fe931976e64c199eddde45068a6c09>:0 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in <42fe931976e64c199eddde45068a6c09>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <20a5debecbfd420ba8345429bf71acbe>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <20a5debecbfd420ba8345429bf71acbe>:0 
  at (wrapper dynamic-method) System.Object:7b8cf35f-416c-4a02-9c9f-ecc98cc8906f (intptr,intptr)
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
	at android.os.Handler.handleCallback(Handler.java:751)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:154)
	at android.app.ActivityThread.main(ActivityThread.java:6209)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Comment 29 Louis Taljaard 2017-08-13 18:49:33 UTC
I am on Xamarin.Forms 2.3.4.247 and getting a similar error. Everything is fine under iOS but it crashes soon after tapping into a details page from a StackLayout list of items, then coming back out to the main list, then tapping into other items in the list . I've tried setting the environment variable "MONO_GC_PARAMS=bridge-implementation=new" as described in other posts where users have been struggling with similar issues when using ListView. Note: Another trick that some guys have been doing to get around this problem is to set <ListView CachingStrategy = "RecycleElement" ...> however that option is not available to me as I'm using a StackLayout and not a ListView.

See my full call stack below, note the top part of the call stack is the came is this bug 45330.

I am not using and 3rd party stuff, only Xamarin Forms.

System.ObjectDisposedException
Cannot access a disposed object.
Object name: 'Android.Widget.ListView'.

  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
  at Android.Widget.ListView.RemoveHeaderView (Android.Views.View v) [0x00027] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/obj/Release/android-25/mcw/Android.Widget.ListView.cs:1200 
  at Xamarin.Forms.Platform.Android.ListViewAdapter.OnDataChanged () [0x00035] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:459 
  at Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:443 
  at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:757 
  at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x0047a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:1100 
  at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:954 
  at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnItemsSourceChanged (System.Boolean fromGrouping) [0x00061] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:935 
  at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].BindableOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00020] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:647 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:136 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:380 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x000f4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:589 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:173 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:55 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:539 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/data/lanes/4695/9dbc4c53/source/xamarin-android/src/Mono.Android/obj/Release/android-25/mcw/Java.Lang.IRunnable.cs:81 
  at (wrapper dynamic-method) System.Object:e8eaa84b-036e-4a2b-9120-d2c5e54de95e (intptr,intptr)
Comment 30 Paul Anderson 2017-08-23 06:25:53 UTC
I am on Xamarin.Forms 2.3.4.247 and getting a similar error. Everything is fine under iOS but it crashes soon after swiping multiple time on Android. Please find the stack trace details from the below link.
Note: we are using Syncfusion Rotator component in our application.
Exception 
08-16 10:08:20.838 I/MonoDroid( 8527): System.ObjectDisposedException: Cannot access a disposed object.
08-16 10:08:20.838 I/MonoDroid( 8527): Object name: 'Android.Views.GestureDetector'.
08-16 10:08:20.838 I/MonoDroid( 8527):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <50812bf827614c0faffacac58772b4fa>:0 
08-16 10:08:20.839 I/MonoDroid( 8527):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <50812bf827614c0faffacac58772b4fa>:0 
08-16 10:08:20.839 I/MonoDroid( 8527):   at Android.Views.GestureDetector.OnTouchEvent (Android.Views.MotionEvent ev) [0x00031] in <71828dd8fb5f4508815e23d6996c45c2>:0 
08-16 10:08:20.839 I/MonoDroid( 8527):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x00051] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:104 
08-16 10:08:20.839 I/MonoDroid( 8527):   at Android.Views.View+IOnTouchListenerInvoker.n_OnTouch_Landroid_view_View_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v, System.IntPtr native_e) [0x00017] in <71828dd8fb5f4508815e23d6996c45c2>:0 
08-16 10:08:20.839 I/MonoDroid( 8527):   at (wrapper dynamic-method) System.Object:d815d26d-627f-4981-bc67-d5c797965a5e (intptr,intptr,intptr,intptr)
08-16 10:08:20.853 W/art     ( 8527): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable

Visual Studio Details:

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.7.02053
Installed Version: Professional
LightSwitch for Visual Studio 2015   00322-50052-66352-AA684
Microsoft LightSwitch for Visual Studio 2015
Visual Basic 2015   00322-50052-66352-AA684
Microsoft Visual Basic 2015
Visual C# 2015   00322-50052-66352-AA684
Microsoft Visual C# 2015
Visual C++ 2015   00322-50052-66352-AA684
Microsoft Visual C++ 2015
Visual F# 2015   00322-50052-66352-AA684
Microsoft Visual F# 2015
Application Insights Tools for Visual Studio Package   7.18.00214.2
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11107.0
ASP.NET and Web Tools 2015.1 (Beta8)
ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563
ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/
Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.
Common Azure Tools   1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
JavaScript Language Service   2.0
JavaScript Language Service
JavaScript Project System   2.0
JavaScript Project System
Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools
NuGet Package Manager   3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools
Syncfusion.VSExtension.Troubleshooter   15.1.0.41
Add-in for Troubleshooting the Syncfusion projects.
TypeScript   1.8.36.0
TypeScript tools for Visual Studio
Visual Studio Tools for Universal Windows Apps   14.0.25527.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
Xamarin   4.2.1.62 (680125b)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android   7.0.2.37 (ce955cc)
Visual Studio extension to enable development for Xamarin.Android.
Xamarin.iOS   10.2.1.5 (44931ae)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 31 David Ortinau [MSFT] 2017-08-23 14:15:06 UTC
Reopening to investigate. 

@Paul if you are able, could you please test with 2.4.0-pre1 and/or the nightly build?

https://github.com/xamarin/Xamarin.Forms/wiki/Nightly-Builds
Comment 32 Samantha Houts 2017-08-23 19:50:03 UTC
I strongly suspect that this issue is resolved by https://github.com/xamarin/Xamarin.Forms/pull/1063. We are having a very difficult time getting this issue reproduced, however. For anyone who is still experiencing this issue, please try the 2.4.0-pre1 release and let us know if it appears to resolve the issue. If not, if you are able to provide us with a reproduction project, that would greatly help.

Thank you!
Comment 33 post4me3 2017-08-28 19:06:15 UTC
Tested with 2.4.0.266 pre 1 and same issue (Only on Droid)

Note - we get this issue with any deeply nested control that has a Gesture Recognizer (Tapped or swiped via renderer) attached. and multiple swipes/taps then exiting view to go back to parent view, then app will crash.

I find it very worrying that there appears to be very little progress on this issue despite the importance raised to highest blocker ????
Comment 34 Louis Taljaard 2017-08-28 19:46:33 UTC
I agree with post4me. This is what I have: ContentPage -> outer/wrapper StackLayout which is assigned to the page's this.Content property -> outer/wrapper PullToRefreshLayout (from package Refactored.XamForms.PullToRefresh) -> outer/wrapper ScrollView -> outer/wrapper StackLayout -> one StackLayout for every row -> each row contains 7 ContentViews -> each of those ContentViews contain a Frame (this.Content = new Frame { Content = StackLayout X} where the StackLayout X has a TapGestureRecognizer assigned to its GestureRecognizers property and there is a Command assigned to the TapGestureRecognizer which calls an OnCellClicked (custom) method. Within that method it does a Navigation.PushModalAsync call to a second page. When user taps in and out of that second page by clicking around on some of the cells with the TapGestureRecogniser, that's when the crash occurs.
Comment 35 Paul Anderson 2017-08-29 10:41:38 UTC
I have checked the reported issue in  Xamarin.forms 2.4.0-pre1 release version and I got nullreference exception on IVisulaelement platforms property. So i couldn't able to check the reported issue "System.ObjectDisposedException". I have also attached the screenshot image for your reference.
Comment 36 Paul Anderson 2017-08-29 10:43:54 UTC
Created attachment 24452 [details]
Nullreference exception on IVisulaelement platforms property

Issue replicating image as been attached.
Comment 37 David Ortinau [MSFT] 2017-08-29 16:05:14 UTC
We'll see with these details if we can reproduce this issue. If anyone can share a project that demonstrates this issue, it would really help tremendously. We are blocked on being able to help until we can reproduce it.
Comment 38 zafar 2017-08-29 18:22:38 UTC
After doing some investigation, I was able to reproduce this issue. It occurs when the following conditions are met on a ListView instance in a given page.

1) The list view item type should implement INotifyPropertyChanged interface.

2) The ListViewCachingStrategy must be RecycleElement.

3) The list view item template should contain at least one visual element whose property is bound to a property in the list view item type. 

4) The ListView including the ContentPage must be garbage collected (i.e popped out of the NavigationStack without having any strong references), While the List view items should still continue to exist i.e not garbage collected.

5) Change some property on the existing list view item type -> Boom Crash!

Note: 

- Crash occurs even though the ItemSource property on the ListView instance is reset to null before popping the page out, so that weak binding references are removed.

Here is the link to repro: https://github.com/ameem85/Xamarin-Forms-Defects/tree/master/45330
Comment 40 Louis Taljaard 2017-08-29 19:07:26 UTC
The is one case where it crashes. Note that when using ListView the problem can be bypassed by changing the ListViewCachingStrategy. But another case is when you don't use ListView at all, as per my example in the earlier Comment 34. If you recreate new a project with the same nested elements you'll get the same crash as the one described there.
Comment 41 post4me3 2017-08-29 19:13:55 UTC
I concur with comment 38 & 40  , i.e the issue definitely manifests itself under this environment (ListView etc) but I just want to point out that I can get this issue without a listview and the conditions to repo are as pointed out in comment 33. 

So again to repeat , the environment that this issue presents itself outside of a ListView is a deeply nested container hierarchy (TAB, Grid, StackLayout etc) and having Gesture Recognizers attached to Labels/Buttons with some INPC binding. Rapidly Tapping around this hierarchy and then CLOSING the view either via ANDROID back button or software will yield this error.
Comment 42 zafar 2017-08-29 19:34:09 UTC
@post4me the issue occurs even if the list view item template container hierarchy is only one level and I am not using any gesture recognizers.
Comment 43 post4me3 2017-08-29 19:45:00 UTC
@zafar - I did clarify my post with :

" ... the environment that this issue presents itself OUTSIDE of a ListView"

and also verified your comment but simply provided additional clarity that this issue is not just ListView related and was simply given another repo ..
Comment 44 Pete 2017-09-15 00:17:23 UTC
I'm seeing a similar issue with Xamarin.Forms v2.4.0.269-pre2. In this case, we have a WebView that receives data through a shim (HybridWebView/HybridWebViewRenderer). This has only been reproduced on a couple of devices running Android 5.11, but that may just be coincidence.
Is this related?

android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Webkit.WebView'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <3211b51724104aed8764bd19dacec531>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <3211b51724104aed8764bd19dacec531>:0 
  at Android.Webkit.WebView.LoadUrl (System.String url) [0x00029] in <c62680c238654ef18ce3e6eef16dbb87>:0 
  at MaxUserApp.Droid.Renderers.HybridWebViewRenderer+<>c__DisplayClass1_0.<InjectJs>b__0 () [0x00020] in <c6e5997d7c884236b93d9dc1db2245db>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <c62680c238654ef18ce3e6eef16dbb87>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <c62680c238654ef18ce3e6eef16dbb87>:0 
  at (wrapper dynamic-method) System.Object:b524b893-7662-40d9-be45-7b17bb037122 (intptr,intptr)
    at mono.java.lang.RunnableImplementor.n_run(Native Method)
    at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6917)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Comment 45 Samantha Houts 2017-09-19 00:37:49 UTC
To all of the users reporting this issue where you are using a ListView, please try updating your projects to use the latest 2.4.0 prerelease and let us know if the problem is resolved. 

Paul Anderson: I'm unable to decipher where NRE is from based on the image you attached. Please try updating to the latest prerelease and let us know if that resolved the issue. If not, we may need to collaborate more.

zafar: Thank you for the GitHub sample. I ran it with the 2.3.4 package and was able to consistently reproduce the error several times. However, upon updating the sample to 2.4.0-pre2, I am no longer able to reproduce the issue. Can you confirm?

Louis Taljaard: I believe that the issue that you are experiencing is related to the PullToRefresh control, as your stack trace is not from a Xamarin.Forms control. There is a related issue regarding a similar problem here: https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout/issues/12

post4me3@gmail.com & Pete Comment 44: Are you able to provide a small reproduction project or snippet that describes the hierarchy and sequence of events required to reproduce the issue?
Comment 46 Pete 2017-09-19 20:56:33 UTC
Samantha Houts: it's pretty much an implementation from the Xamarin guide:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/hybridwebview/
Thanks.

(I've been looking at it closely, and I'm not sure if this is related, but I can see that OnElementChanged in HybridWebViewRenderer is never called with a non-null OldElement value, so it never gets cleaned up.)
Comment 47 Louis Taljaard 2017-09-20 14:49:59 UTC
samantha.houts@xamarin.com : I have removed the pull to refresh completely and it is still giving exectly the same error. This is what I have now: ContentPage -> outer/wrapper StackLayout which is assigned to the page's this.Content property -> outer/wrapper ScrollView -> outer/wrapper StackLayout -> one StackLayout for every row -> each row contains 7 ContentViews -> each of those ContentViews contain a Frame (this.Content = new Frame { Content = StackLayout X} where the StackLayout X has a TapGestureRecognizer assigned to its GestureRecognizers property and there is a Command assigned to the TapGestureRecognizer which calls an OnCellClicked (custom) method. Within that method it does a Navigation.PushModalAsync call to a second page. When user taps in and out of that second page by clicking around on some of the cells with the TapGestureRecogniser, that's when the crash occurs.
Comment 48 Louis Taljaard 2017-09-20 15:23:36 UTC
samantha.houts@xamarin.com : My call stack now (without the pull to refresh control) looks like this:

System.Diagnostics.Debugger.Mono_UnhandledException_internal() in 
System.Diagnostics.Debugger.Mono_UnhandledException(System.ObjectDisposedException ex) in 
object.7289afd9-c521-4e0f-9eca-c4676649638e( arg0,  arg1) in 
Java.Interop.JniPeerMembers.AssertSelf(Android.Widget.ListView self) in 
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualBooleanMethod(string encodedMember, Android.Widget.ListView self, Java.Interop.JniArgumentValue* parameters) in 
Android.Widget.ListView.RemoveHeaderView(Xamarin.Forms.Platform.Android.ListViewRenderer.Container v) in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/obj/Release/android-25/mcw/Android.Widget.ListView.cs:1200
Xamarin.Forms.Platform.Android.ListViewAdapter.OnDataChanged() in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:459
Xamarin.Forms.Platform.Android.ListViewAdapter.OnCollectionChanged(Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell> sender, Xamarin.Forms.Internals.NotifyCollectionChangedEventArgsEx e) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:443
Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.OnCollectionChanged(Xamarin.Forms.Internals.NotifyCollectionChangedEventArgsEx e) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:757
Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.OnProxyCollectionChanged(Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell> sender, Xamarin.Forms.Internals.NotifyCollectionChangedEventArgsEx e, bool fixWindows) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:1100
Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.OnProxyCollectionChanged(Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell> sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:954
Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.OnItemsSourceChanged(bool fromGrouping) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:935
Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.BindableOnPropertyChanged(Xamarin.Forms.ListView sender, System.ComponentModel.PropertyChangedEventArgs e) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedItemsList.cs:647
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:136
Xamarin.Forms.Element.OnPropertyChanged(string propertyName) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:380
Xamarin.Forms.BindableObject.SetValueActual(Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject.BindablePropertyContext context, System.Collections.ObjectModel.ObservableCollection<ImAvail.ViewModels.AvailabilityViewModel> value, bool currentlyApplying, Xamarin.Forms.BindableObject.SetValueFlags attributes, bool silent) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:589
Xamarin.Forms.BindableObject.SetValueCore(Xamarin.Forms.BindableProperty property, System.Collections.ObjectModel.ObservableCollection<ImAvail.ViewModels.AvailabilityViewModel> value, Xamarin.Forms.BindableObject.SetValueFlags attributes, Xamarin.Forms.BindableObject.SetValuePrivateFlags privateAttributes) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386
Xamarin.Forms.BindingExpression.ApplyCore(ImAvail.ViewModels.AvailabilitiesPerDayViewModel sourceObject, Xamarin.Forms.ListView target, Xamarin.Forms.BindableProperty property, bool fromTarget) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:173
Xamarin.Forms.BindingExpression.Apply(bool fromTarget) in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:55
Xamarin.Forms.BindingExpression.BindingExpressionPart.<PropertyChanged>b__47_0() in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:539
Java.Lang.Thread.RunnableImplementor.Run() in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/src/Mono.Android/obj/Release/android-25/mcw/Java.Lang.IRunnable.cs:81
object.7289afd9-c521-4e0f-9eca-c4676649638e( arg0,  arg1) in
Comment 49 Samantha Houts 2017-09-20 16:43:54 UTC
Louis Taljaard: Your call stack is showing a ListView, but you don't mention a ListView anywhere in your hierarchy. Is there any way you can share your project with me so I can see what's happening?

Pete Comment 46: I'll see if I can reproduce the issue with the HybridWebView today.
Comment 50 post4me3 2017-09-20 18:42:26 UTC
Potentially this issue is not just constrained to ListView/GestureRecognizers within Android - I have also found that the issue presents itself by having a binding to a TableSection - no ListView at all. Thus, I just have a simple APP that has a button which navigates to another view - this view has a TabbedPage containing 3 TABS , each TAB page has a table section which has a BINDING for TableSection title, something like this :


 <StackLayout>


        <TableView Intent="Settings">
            <TableRoot>
                <TableSection Title="{Binding OtherTitle, Mode=TwoWay}">
                    <ViewCell>
                        <Label Text="Will crash second/third time you open this view" TextColor="Red" />
                    </ViewCell>
                </TableSection>
            </TableRoot>
        </TableView>
    </StackLayout>


the 'OtherTitle' is set in the VM that backs the View. 

So when I run this APP - I have to quickly navigate from Main Page to this view and then touch each TAB (ALL 3 of them) in quick succession - then navigate back to the MainPage - I repeat this process and then the app crashes.

For this particular issue below, could be related to the change made to :

Xamarin.Forms/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs

on Dec 6/2016 regarding " Don't render empty TextCells for TableSections without Title (bugs 26104 and 42926)"

Stack trace :

android.runtime.JavaProxyThrowable: System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.AggregateException: One or more errors occurred. ---> System.Exception: Cannot destroy Module.TabMenu. ---> System.Exception: Cannot destroy Module.TabMenu.SettingsTheme. ---> System.ObjectDisposedException: Cannot access a disposed object.
caused.AggregateException(s)
Object name: 'Xamarin.Forms.Platform.Android.TableViewModelRenderer'.
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<6cd960837cc24c26bab2a0a29b597627>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<6cd960837cc24c26bab2a0a29b597627>:0
Android.Widget.BaseAdapter.NotifyDataSetChanged()<06064416b46d4ffbb3484c957929a39f>:0
at Xamarin.Forms.Platform.Android.TableViewModelRenderer.<.ctor>b__14_0 (System.Object sender, System.EventArgs args) [0x00006] in <74ac3f29fabc4c9bbfe3c4108a7356b8>:0
Xamarin.Forms.TableView.OnModelChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.TableView.OnTableModelRootPropertyChanged(object sender, PropertyChangedEventArgs e)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.TableRoot.ChildPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindingExpression.Apply(object sourceObject, BindableObject target, BindableProperty property)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Binding.Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.ApplyBindings(bool skipBindingContext)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.ApplyBindings()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.TableSectionBase<T>.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.TableView.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Element.SetChildInheritedBindingContext(Element child, object context)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Element.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.View.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Element.SetChildInheritedBindingContext(Element child, object context)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.TemplatedPage.SetChildInheritedBindingContext(Element child, object context)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Element.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.Page.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.ContentPage.OnBindingContextChanged()<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, BindableObject.SetValueFlags attributes, bool silent)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, BindableObject.SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.BindableObject.set_BindingContext(object value)<7fc7c54b5e2d419395df064dc5addbb6>:0
Prism.Common.PageUtilities.DestroyPage(Page page)<7a32c28f35024e719a93e31b4d1e3d2a>:0
--- End of inner exception stack trace ---
Prism.Common.PageUtilities.DestroyPage(Page page)<7a32c28f35024e719a93e31b4d1e3d2a>:0
Prism.Common.PageUtilities.DestroyChildren(Page page)<7a32c28f35024e719a93e31b4d1e3d2a>:0
Prism.Common.PageUtilities.DestroyPage(Page page)<7a32c28f35024e719a93e31b4d1e3d2a>:0
--- End of inner exception stack trace ---
Prism.Common.PageUtilities.DestroyPage(Page page)<7a32c28f35024e719a93e31b4d1e3d2a>:0
Prism.Common.PageUtilities.HandleSystemGoBack(Page previousPage, Page currentPage)<7a32c28f35024e719a93e31b4d1e3d2a>:0
Prism.Behaviors.NavigationPageSystemGoBackBehavior.NavigationPage_Popped(object sender, NavigationEventArgs e)<7a32c28f35024e719a93e31b4d1e3d2a>:0
at Xamarin.Forms.NavigationPage+<Xamarin-Forms-INavigationPageController-PopAsyncInner>d__63.MoveNext () [0x0016b] in <7fc7c54b5e2d419395df064dc5addbb6>:0
Xamarin.Forms.NavigationPage.<PopAsync>d__38.MoveNext()<7fc7c54b5e2d419395df064dc5addbb6>:0
--- End of inner exception stack trace ---
Xamarin.Forms.NavigationPage.<>c.<SafePop>b__93_0(Task<TResult> t)<7fc7c54b5e2d419395df064dc5addbb6>:0
System.Threading.Tasks.ContinuationTaskFromResultTask<TAntecedentResult>.InnerInvoke()<896ad1d315ca4ba7b117efb8dacaedcf>:0
System.Threading.Tasks.Task.Execute()<896ad1d315ca4ba7b117efb8dacaedcf>:0
--- End of inner exception stack trace ---


Is the status still NEEDINFO - or do we now have something tangible to work with as it would appear there are numerous examples now with which presumably we can run with ?
Comment 51 Louis Taljaard 2017-09-20 19:02:47 UTC
samantha.houts@xamarin.com : I'm not using a ListView directly. Perhaps it is Xamarin.Forms.Cell or Xamarin.Forms.TemplatedItemsList that is using a ListView internally. I can't share my project but we could set up a screen share session if that would help. Email me if you want to do that.
Comment 52 Samantha Houts 2017-09-20 22:15:32 UTC
Created attachment 24842 [details]
TableView Test

post4me3@gmail.com: I've attached a project with a TableView as you have described. I am not seeing a crash. Can you please take a look at the project and make any adjustments necessary to cause the problem? Thank you.
Comment 53 Samantha Houts 2017-09-20 22:47:02 UTC
Created attachment 24843 [details]
TableView/HybridWebView Test

Pete Comment 46: I have updated the TableView/HybridWebView Test project to include the HybridWebView sample control. It does not crash for me. I know you mentioned that it was intermittent, but I wonder if you could take a look at the project to see if there is something you can add to invoke the crash.

Thank you.
Comment 54 Samantha Houts 2017-09-20 22:57:27 UTC
Louis Taljaard: It sounds like you are creating your own control similar to a repeater rather than using the ListView or TableView, but you are using the Cell and/or TemplatedItemsList classes? 

If you are inflating views dynamically into your own control wrappers, then you may run into the same problem that we had with the ListView that we resolved in 2.4.0, and you may need to make the same changes to your custom control. 

Basically, you'll need to make a custom renderer class for Android, and when it is Disposed, you should loop through all of the Cells that your control contains and explicitly clear the Renderer property and then dispose them. See https://github.com/xamarin/Xamarin.Forms/pull/1063/files#diff-531c2ad3fc214f367ccbc4f65287401bR399 for what we did to resolve the issue for ListView.
Comment 55 Pete 2017-09-21 05:55:04 UTC
Hi Samantha, thanks for taking a look. I've spun up your sample and I can't repo the issue, but then I've never seen it first hand anyway. It was only happening on 1 or 2 particular devices (v5.1.1 I think, if that makes a difference) and only once or twice a day with heavy use. It's probably only going to be found by staring at code unfortunately...

Probably unrelated, but I see OnElementChanged is never called with an OldElement, so cleanup never occurs. I think it may have been called with older versions of Xamarin but I can't confirm that.

Thanks you trying though :-)
Comment 56 Samantha Houts 2017-09-23 00:36:13 UTC
Just submitted https://github.com/xamarin/Xamarin.Forms/pull/1155 to pick up any issues with HeaderTemplates and/or FooterTemplates. Hopefully, this will resolve any persisting issues with ListViews.
Comment 57 Louis Taljaard 2017-09-23 07:56:05 UTC
Samantha Houts: I haven't done the custom renderer, but just discovered my case actually has to do with the page that is being navigated TO i.e. the 2nd page and not the origin/1st page. On the 2nd page I have a ListView (with a DataTemplate which is based on a ListItemViewCell-derived class). The crash is occurring within the processing of the 2nd page and not the 1st page. That is why we see a ListView as part of the call stack. I use the PullToRefreshLayout from James Montemagno on the 2nd page. If I remove the PullToRefreshLayout and replace that functionality with the built-in IsPullToRefreshEnabled=True of the standard ListView the crash no longer happens (I only need to remove the PullToRefreshLayout from the 2nd page - it all still works fine even if I continue to use the PullToRefreshLayout on the 1st page).

Even though my issue is now sorted out (I'll stop using PullToRefreshLayout) I still think that this case may help you find the underlying cause of this bug/memory issue. I say that because I have been using the PullToRefreshLayout throughout my app, and the only place that it leads to a crash (confirmed through extensive testing) is on the 1st page that I have been describing with all the cells with the Gesture detector on. If you want to simulate my case you can do the following:

Page 1: as I described before: ContentPage -> outer/wrapper StackLayout which is assigned to the page's this.Content property -> outer/wrapper ScrollView -> outer/wrapper StackLayout -> one StackLayout for every row -> each row contains 7 ContentViews -> each of those ContentViews contain a Frame (this.Content = new Frame { Content = StackLayout X} where the StackLayout X has a TapGestureRecognizer assigned to its GestureRecognizers property and there is a Command assigned to the TapGestureRecognizer which calls an OnCellClicked (custom) method. Within that method it does a Navigation.PushModalAsync call to a second page.

Page 2: ContentPage -> this.Content = outer/wrapper StackLayout -> PullToRefreshLayout -> ListView (DataTemplate with a a ListItemViewCell-derived class).

Once you have the above running you can click in & out of the cells on the 1st page to go to the 2nd page then back again. For me I must do this exactly 3 times and it crashes consistently on the 4th time.

Hope that may help you to find the problem.

Note You need to log in before you can comment on or make changes to this bug.