FastRenderers.ImageRenderer Bug - ObjectDisposedException: Cannot access a disposed object.

M0BilalM0Bilal USMember ✭✭
edited July 15 in Xamarin.Forms

I am hurting my brain since last one week on an issue. I am using CrossMedia plugin to capture photo's. The flow of the application is something like this:
1. Main page with 4 tab pages. (PAGE 1)
2. On second tab page there is a list with custom template.
3. A page that is accessible from the second tab (mentioned in step 2) (PAGE 2)
4. On PAGE 2 there is a button, on tapping which I call CrossMedia plugin and capture photo.

As soon as I return to PAGE 2 after capturing photo. I get following error. I am carefully following this instruction from James. But still getting this error.

System.ObjectDisposedException: Cannot access a disposed object.
07-15 18:30:00.484 E/AppCenterCrashes(30572): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer'.
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <3beddfcb1eb547cd8ce47c3097f6eaeb>:0
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Android.Views.View.get_Visibility () [0x0000a] in :0
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateIsVisible () [0x00017] in D;\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:327
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.Platform.Android.VisualElementTracker.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00347] in D;\a\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:169
07-15 18:30:00.484 E/AppCenterCrashes(30572): at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D;\a\1\s\Xamarin.Forms.Core\BindableObject.cs:211
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D;\a\1\s\Xamarin.Forms.Core\Element.cs:359
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D;\a\1\s\Xamarin.Forms.Core\BindableObject.cs:443
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D;\a\1\s\Xamarin.Forms.Core\BindableObject.cs:379
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00220] in D;\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:167
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D;\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:57
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Xamarin.Forms.BindingExpression+BindingExpressionPart.b__49_0 () [0x00000] in D;\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:618
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in :0
07-15 18:30:00.484 E/AppCenterCrashes(30572): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in :0
07-15 18:30:00.484 E/AppCenterCrashes(30572): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.46(intptr,intptr)

Answers

  • M0BilalM0Bilal USMember ✭✭
    edited July 16

    Gave it another couple of hours, and came to know that the listview at tab page is the real culprit. There is an Image in the ItemTemplate of that listview. When navigating to PAGE 2, I pass the selected item to PAGE 2. On this page, that selected item gets change. And since there is a binding of a property of this object with Image on ListView ItemTemplate; so that gets updated. And since the Image object is disposed by that time and binding is trying to update the property of Disposed Image, so I am getting this error.

    Now the question is, how do I achieve this? I want to update a binded property on a Listview's itemTemplate that is on previous page. When I am at PAGE 2, that Image in ItemTemplate is disposed.

Sign In or Register to comment.