Rg.Plugins.Popup: Android 7.1.2 - System.ObjectDisposedException: Cannot access a disposed object.

I’m using Rg.Plugins.Popup in my Xamarin.Forms app.

Per not, I haven’t much issues with Android (there are some on iOS), but today I had exception, that I’m no able to reproduce again.

However the stacktrace might be helpful to find the root cause:

Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'. Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<bd30a18775d94dc8b6263aecd1ca9077>:0 Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<bd30a18775d94dc8b6263aecd1ca9077>:0 Android.Views.View.SetBackgroundColor(Color color)<d855bac285f44dda8a0d8510b679b1e2>:0 Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.UpdateBackgroundColor()<3364a2d206a142d8a54cb7a9b77626da>:0 Xamarin.Forms.Platform.Android.VisualElementRenderer<TElement>.OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) <Module>.invoke_void_object_PropertyChangedEventArgs(object, PropertyChangedEventArgs)(wrapper delegate-invoke) Xamarin.Forms.BindableObject.OnPropertyChanged(string propertyName) Xamarin.Forms.Element.OnPropertyChanged(string propertyName) Xamarin.Forms.BindableObject.ClearValue(BindableProperty property, bool checkaccess) Xamarin.Forms.BindableObject.ClearValue(BindableProperty property) Xamarin.Forms.Setter.UnApply(BindableObject target, bool fromStyle) Xamarin.Forms.TriggerBase.OnConditionChanged(BindableObject bindable, bool oldValue, bool newValue) Xamarin.Forms.BindingCondition.OnBoundPropertyChanged(BindableObject bindable, object oldValue, object newValue) Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent) Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes) Xamarin.Forms.BindingExpression.ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget) Xamarin.Forms.BindingExpression.Apply(object sourceObject, BindableObject target, BindableProperty property) Xamarin.Forms.Binding.Apply(object newContext, BindableObject bindObj, BindableProperty targetProperty) Xamarin.Forms.BindableObject.ApplyBindings(bool skipBindingContext) Xamarin.Forms.BindableObject.ApplyBindings() Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, object value) Xamarin.Forms.Element.SetChildInheritedBindingContext(Element child, object context) Xamarin.Forms.Element.OnBindingContextChanged() Xamarin.Forms.Cell.OnBindingContextChanged() Xamarin.Forms.BindableObject.BindingContextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue) Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, BindableObject.BindablePropertyContext context, object value, bool currentlyApplying, SetValueFlags attributes, bool silent) Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, object value, SetValueFlags attributes, BindableObject.SetValuePrivateFlags privateAttributes) Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value, bool fromStyle, bool checkAccess) Xamarin.Forms.BindableObject.SetValue(BindableProperty property, object value) Xamarin.Forms.BindableObject.set_BindingContext(object value) Xamarin.Forms.Internals.TemplatedItemsList<TView, TItem>.<UnhookItem>d__153.MoveNext() Android.App.SyncContext.<>c__DisplayClass2_0.<Post>b__0()<d855bac285f44dda8a0d8510b679b1e2>:0 Java.Lang.Thread.RunnableImplementor.Run()<d855bac285f44dda8a0d8510b679b1e2>:0 Java.Lang.IRunnableInvoker.n_Run(IntPtr jnienv, IntPtr native__this)<d855bac285f44dda8a0d8510b679b1e2>:0 at (wrapper dynamic-method) System.Object:a960454b-0830-44c5-ae98-58470dadd3eb (intptr,intptr) mono.java.lang.RunnableImplementor.n_run(Native Method) mono.java.lang.RunnableImplementor.run()RunnableImplementor.java:30 android.os.Handler.handleCallback()Handler.java:751 android.os.Handler.dispatchMessage()Handler.java:95 android.os.Looper.loop()Looper.java:154 android.app.ActivityThread.main()ActivityThread.java:6186 java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:889 com.android.internal.os.ZygoteInit.main()ZygoteInit.java:779

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 24 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I am getting this error with latest version.

My popup contains an Editor control which would be focused at time of closing popup.

Which leads me to believe it must be caused by something around this line:

https://github.com/rotorgames/Rg.Plugins.Popup/blob/cf657634fe6cf50beb2a3c40c2939b869a89c647/src/Rg.Plugins.Popup.Droid/Renderers/PopupPageRenderer.cs#L144

I believe I am seeing the same issue. It happens on a variety of devices and OS versions. I’m using 1.1.4.154-pre, and I didn’t see this issue prior to the update (previously using 1.0.4)

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Rg.Plugins.Popup.Droid.Renderers.PopupPageRenderer'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <ff59c385c496418caa679915da0cb5a1>:0
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <ff59c385c496418caa679915da0cb5a1>:0
  at Android.Views.View.get_Context () [0x0000a] in <b72ad63c794e4736b6b75797df08ae7d>:0
  at Rg.Plugins.Popup.Droid.Renderers.PopupPageRenderer.DispatchTouchEvent (Android.Views.MotionEvent e) [0x00055] in <d927ed3c90894f1eb311e2dc2f5953ba>:0
  at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x0000f] in <b72ad63c794e4736b6b75797df08ae7d>:0
  at (wrapper dynamic-method) System.Object.d3bd19aa-c4c7-4fca-a7cc-58bc75fc8b6e(intptr,intptr,intptr)