question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
JKennedy24commented, Aug 29, 2018

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

1reaction
kpespisacommented, Jun 7, 2018

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)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot access a disposed object. A common cause of this ...
A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the...
Read more >
"Cannot access a disposed object." exception when ...
It looks like there's a problem in the Dispose method of the Grid: [mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: ...
Read more >
Cannot access a disposed object. Object name: 'Android. ...
I am getting the same issue : It is very random, sometimes it occurs sometime not. System.ObjectDisposedException: Cannot access a disposed ...
Read more >
ObjectDisposedException Class (System)
An ObjectDisposedException is thrown when you try to access a member of an object that implements the IDisposable interface or IAsyncDisposable interface, and ......
Read more >
Cannot access a disposed object. Object name
I've created a new NAV Instance, setup the correct database name then tried to run the Service and I've received the following error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found