Bug 57758 - ObjectDisposedException for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer
Summary: ObjectDisposedException for Xamarin.Forms.Platform.Android.FastRenderers.Imag...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.5
Hardware: PC Windows
: Normal blocker
Target Milestone: ---
Assignee: E.Z. Hart [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2017-06-26 13:21 UTC by graham
Modified: 2017-07-07 02:23 UTC (History)
4 users (show)

Tags: ac android fastrenderer imagerenderer fr
Is this bug a regression?: Yes
Last known good build: 2.3.5-pre3


Attachments
repro project (295.20 KB, application/x-zip-compressed)
2017-06-26 15:35 UTC, Jimmy [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description graham 2017-06-26 13:21:13 UTC
# Steps to reproduce
Created a control that sits as child of a StackLayout that includes an Image (delete button) with a TapGestureRecogniser. The handler of the TapGestureRecogniser removes the control instance from the StackLayout.

# Expected behavior
App doesn't crash

# Actual behavior
App crashes with unhandled ObjectDisposedException, Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'. 
Stack trace:
Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <bd30a18775d94dc8b6263aecd1ca9077>:0 
Android.Views.View.get_LongClickable () [0x0000a] in <d855bac285f44dda8a0d8510b679b1e2>:0 
Xamarin.Forms.Platform.Android.ViewCellExtensions.EnsureLongClickCancellation (Android.Views.View view, Android.Views.MotionEvent motionEvent, System.Boolean handled, Xamarin.Forms.VisualElement element) [0x00000] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:847 
Xamarin.Forms.Platform.Android.FastRenderers.GestureManager.global::Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0009a] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\TabbedPageRenderer.cs:229 
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 <d855bac285f44dda8a0d8510b679b1e2>:0 
(wrapper dynamic-method) System.Object:69c79059-bb17-4d03-b397-bbc8ecf513d7 (intptr,intptr,intptr,intptr)

# Supplemental info (logs, images, videos)
This only occurs with Android. The app works on iOS and UWP as intended. Also, this worked on Android in 2.3.5-pre3

# Test environment (full version information)
XF 2.3.5-pre5
Comment 1 Jimmy [MSFT] 2017-06-26 15:35:21 UTC
Created attachment 23118 [details]
repro project

I am attaching a project that reproduces this issue on 2.3.5-pre5. The crash did not occur with 2.3.5-pre3 so this does appear to be a regression.

> UNHANDLED EXCEPTION:
> System.ObjectDisposedException: Cannot access a disposed object.
> Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
> 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.Views.View.get_LongClickable () [0x0000a] in <d855bac285f44dda8a0d8510b679b1e2>:0 
> at Xamarin.Forms.Platform.Android.ViewCellExtensions.EnsureLongClickCancellation (Android.Views.View view, Android.Views.MotionEvent motionEvent, System.Boolean handled, Xamarin.Forms.VisualElement element) [0x00000] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:847 
> at Xamarin.Forms.Platform.Android.FastRenderers.GestureManager.global::Android.Views.View.IOnTouchListener.OnTouch (Android.Views.View v, Android.Views.MotionEvent e) [0x0009a] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\TabbedPageRenderer.cs:229 
> 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 <d855bac285f44dda8a0d8510b679b1e2>:0 
> at (wrapper dynamic-method) System.Object:68e3db45-74e3-4246-a369-371073718932 (intptr,intptr,intptr,intptr)


Complete debug output: https://gist.github.com/jimmgarrido/90fd55bfbaf85c3fb6d2296aae502545


### Steps to Reproduce
1. Run the Android project
2. Tap the image
Comment 2 E.Z. Hart [MSFT] 2017-06-26 17:02:39 UTC
PR: https://github.com/xamarin/Xamarin.Forms/pull/1016
Comment 3 Samantha Houts [MSFT] 2017-07-07 02:23:29 UTC
Should be fixed in 2.3.5 stable. Thank you!