Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Bitmap'. #2746

Closed
balaameex opened this issue May 16, 2018 · 10 comments
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. t/bug 🐛

Comments

@balaameex
Copy link

Description

This error occurs when navigating between pages. Since no user code is involved it's not possible to catch and handle the exception.

Xamarin caused by: android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Android.Graphics.Bitmap'.
Java.Interop.JniPeerMembers.AssertSelf(IJavaPeerable self)<7bd6e23e74244e9191c46983d3bb2eeb>:0
Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractVoidMethod(string encodedMember, IJavaPeerable self, JniArgumentValue* parameters)<7bd6e23e74244e9191c46983d3bb2eeb>:0
Android.Graphics.Bitmap.Recycle()<82958282c7e341b985c12639e88fc1d1>:0
Xamarin.Forms.Platform.Android.ButtonDrawable.Reset()<173f39d71f0d4d928f5bbea42e96ffa8>:0
Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose(bool disposing)<173f39d71f0d4d928f5bbea42e96ffa8>:0
Java.Lang.Object.Dispose()<82958282c7e341b985c12639e88fc1d1>:0
Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose(bool disposing)<173f39d71f0d4d928f5bbea42e96ffa8>:0
Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose()<173f39d71f0d4d928f5bbea42e96ffa8>:0
Xamarin.Forms.Platform.Android.ButtonRenderer.Dispose(bool disposing)<173f39d71f0d4d928f5bbea42e96ffa8>:0
Java.Lang.Object.Dispose()<82958282c7e341b985c12639e88fc1d1>:0
Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose(bool disposing)<173f39d71f0d4d928f5bbea42e96ffa8>:0
Xamarin.Forms.Platform.Android.PageRenderer.Dispose(bool disposing)<173f39d71f0d4d928f5bbea42e96ffa8>:0
Java.Lang.Object.Dispose()<82958282c7e341b985c12639e88fc1d1>:0
Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView()<173f39d71f0d4d928f5bbea42e96ffa8>:0
Android.Support.V4.App.Fragment.n_OnDestroyView(IntPtr jnienv, IntPtr native__this)<40bb5a57295c4f648daa62e9e7aa774b>:0
at (wrapper dynamic-method) System.Object.84698d0a-0c20-40fc-87af-f3c645d9eec0(intptr,intptr)
md58432a647068b097f9637064b8985a5e0.FragmentContainer.n_onDestroyView(Native Method)
md58432a647068b097f9637064b8985a5e0.FragmentContainer.onDestroyView()FragmentContainer.java:59
android.support.v4.app.Fragment.performDestroyView()Fragment.java:2590
android.support.v4.app.FragmentManagerImpl.moveToState()FragmentManager.java:1503
android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState()FragmentManager.java:1740
android.support.v4.app.BackStackRecord.executeOps()BackStackRecord.java:794
android.support.v4.app.FragmentManagerImpl.executeOps()FragmentManager.java:2580
android.support.v4.app.FragmentManagerImpl.executeOpsTogether()FragmentManager.java:2367
android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute()FragmentManager.java:2322
android.support.v4.app.FragmentManagerImpl.execPendingActions()FragmentManager.java:2229
android.support.v4.app.FragmentManagerImpl$1.run()FragmentManager.java:700
android.os.Handler.handleCallback()Handler.java:739
android.os.Handler.dispatchMessage()Handler.java:95
android.os.Looper.loop()Looper.java:168
android.app.ActivityThread.main()ActivityThread.java:5845
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:797
com.android.internal.os.ZygoteInit.main()ZygoteInit.java:687

Steps to Reproduce

Happened Intermittently, No steps to reproduce.
But it is happened and crashed the app and reported in Hockey.

Expected Behavior

It should not crash the app.

Actual Behavior

It is crashing the app

Basic Information

  • Version with issue: 2.5.0.280555
  • Last known good version: N/A
  • IDE: Visual studio for Mac
  • Platform Target Frameworks:
    • iOS: Working fine
    • Android: 8.0
    • UWP: N/A
  • Android Support Library Version: 26.1.0.1
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

@pauldipietro
Copy link
Contributor

Any sort of reproduction, even if it causes crashes intermittently, would be extremely helpful here.

@pauldipietro pauldipietro added t/bug 🐛 p/Android s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. labels May 16, 2018
@balaameex
Copy link
Author

I do not have any reproduce steps, It happened sporadically, This was happened 11 times in last two months, Got it from Hockey report.

@GalaxiaGuy
Copy link
Contributor

I just thought I'd reference possibly duplicate bugs:

#2004
#2041
#2317 (https://bugzilla.xamarin.com/show_bug.cgi?id=57789)

I do realise ObjectDisposedException is general enough that unrelated issues could cause them. However all three above are also Android.Graphics.Bitmap and two of them also happen in ButtonBackgroundTracker while a page is being disposed.

@mtarros
Copy link

mtarros commented May 17, 2018

I had the same issue and found out that it was caused by having a button in a list view cell and the table had a long press. I got around it by changing the button to a tap gesture.

@balaameex
Copy link
Author

Hi mtarros,

Are you able to reproduce your issue consistently? and able to resolve?, My issue is happening intermittently and unable to reproduce again and it is happening sporadically.

@mtarros
Copy link

mtarros commented May 20, 2018

It would happen intermittently also, but we did work out the steps to repeat the issue. I think it was just repeating browsing between two screens.

Removing the button from the list view cell and replacing it with an image and a tap gesture solved the issue.

@mfeingol
Copy link

I'm seeing something fairly similar inside a Xamarin Forms app on Android. The affected page has the same layout mentioned by @mtarros: a grouped listview containing items with buttons.

The issue is somewhat difficult to reproduce, but for me it happens when something on the page causes the buttons to be destroyed and recreated. E.g. if you use a grouping listview and remove / re-add items to a group when the group header is tapped (which leads to an expand/collapse effect), you'll be inducing the repro scenario.

My stack trace from debugger output:

05-20 11:01:46.813 I/MonoDroid(25875): UNHANDLED EXCEPTION:
05-20 11:01:46.815 I/MonoDroid(25875): System.ObjectDisposedException: Cannot access a disposed object.
05-20 11:01:46.815 I/MonoDroid(25875): Object name: 'Android.Graphics.Bitmap'.
05-20 11:01:46.815 I/MonoDroid(25875):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <09bf3e262b934ffab2ba01f9fc7fd54d>:0 
05-20 11:01:46.815 I/MonoDroid(25875):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualInt32Method (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <09bf3e262b934ffab2ba01f9fc7fd54d>:0 
05-20 11:01:46.815 I/MonoDroid(25875):   at Android.Graphics.Bitmap.get_Height () [0x0000a] in <25661073a35344a89f215a4cf81af37c>:0 
05-20 11:01:46.815 I/MonoDroid(25875):   at Xamarin.Forms.Platform.Android.ButtonDrawable.Draw (Android.Graphics.Canvas canvas) [0x00021] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:66 
05-20 11:01:46.815 I/MonoDroid(25875):   at Android.Graphics.Drawables.Drawable.n_Draw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x0000f] in <25661073a35344a89f215a4cf81af37c>:0 
05-20 11:01:46.816 I/MonoDroid(25875):   at (wrapper dynamic-method) System.Object.cea1b8bb-4918-44f8-90bd-fb3c78d91bd8(intptr,intptr,intptr)

@PureWeen
Copy link
Contributor

#2421

@PureWeen
Copy link
Contributor

I created a central issue for this type of exception
#2829

And I'm going to close this one for now
If you don't feel like the issue I created represents the problem here just let me know and we can reopen

@PureWeen
Copy link
Contributor

PureWeen commented Aug 3, 2018

#3459

in the upcoming 3.2 should resolve this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/Android s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. t/bug 🐛
Projects
None yet
Development

No branches or pull requests

6 participants