Xamarin.forms: System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Bitmap'

Created on 7 Mar 2018  ·  18Comments  ·  Source: xamarin/Xamarin.Forms

Bug report best practices: https://github.com/xamarin/Xamarin.Forms/wiki/Submitting-Issues

Description

Steps to Reproduce

  1. Actually I made a listview and makes a rest call to retrieve data
  2. Listview gets populated on scrolling
  3. And also i kept a search bar to search the content.

Expected Behavior

Search should happen and make a rest call and listview should be populated without error

Actual Behavior

while searching , sometimes (at irregular intervals of time) i get System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Bitmap' this exception and my app gets unfortunately stopped.

Basic Information

I kept a round button in each row of a listview by using ButtonCircle.FormsPlugin.Abstractions plugin and sets background color of the button using random function.

  • Version with issue:
  • Last known good version:Visual Studio 15.5.6
  • IDE: Visual Studio , Xamarin.Forms
  • Platform Target Frameworks: Android 4.0.3 to Android 8.0

    • Android: Android 8.0
  • Android Support Library Version:

  • Nuget Packages: ButtonCircle.FormsPlugin.Abstractions
  • Affected Devices:

Screenshots

Reproduction Link

needs-info ❓ needs-repro ❔

Most helpful comment

Started to receive this issue with latest update of Xamarin Forms 3.1.0.583944

Fatal Exception: java.lang.Throwable: Cannot access a disposed object.
Object name: 'Android.Graphics.Bitmap'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)(filename unknown)
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)(filename unknown)
at Android.Graphics.Bitmap.Recycle ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonDrawable.Reset ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose (System.Boolean disposing)(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonRenderer.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown) at Java.Lang.Object.Dispose ()(filename unknown) at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown) at Java.Lang.Object.Dispose ()(filename unknown) at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing)(filename unknown)
at JobseekerApp.Droid.Renderers.ReedContentPageRenderer.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView ()(filename unknown)
at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this)(filename unknown)

All 18 comments

@jeevan9 how are you using the random function for colors? Could show that please?

if your not able to do a reproduction project, please paste the stacktrace. Othwerwise its very hard to se where this bug is happening

As @bentmar said, without either a reproduction or a stack trace this is going to be a very long time before we get to this.

I have same issue...

Stacktrace:
MyIconButtonRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e)
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Bitmap'.
JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Bitmap.Recycle ()
ButtonDrawable.Reset ()
ButtonRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e) MyIconButtonRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e)
VisualElementRenderer1[TElement].SetElement (TElement element)

@jerry2007 this crash comes from a custom renderer (not provided by the xamarin team)

@jerry2007 Does your custom renderer override OnElementChanged?

 private async Task Get_Projects_Search_List()
        {
            await Get_Projects_Search();           
            foreach (var item in projects_search.Value)
            {
                item.Back_color_str = string.Format("#{0:X6}", new Random().Next(0x1000000));                   
                item.Start_letter = item.ProjectId.Substring(0, 1);
                FilteredList.Add(item);
            }
        }

  private async Task Get_Projects_Search()
        {
            HttpClient client = new HttpClient();          
            string url ="xxx";
            var uri = new Uri(string.Format(url, searchText));

            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("Authorization", MainPage.Token);
            var response = await client.GetAsync(uri);
            if (response.IsSuccessStatusCode)
            {
                var content =await response.Content.ReadAsStringAsync();
                projects_search = JsonConvert.DeserializeObject<RootProject>(content);
            }
        }

This is how i generate a random hexadecimal color using random class.
and i get an error when i make a search using search bar. If the color is not given it works fine.
Below is an attachment displaying my error.So, i request you to resolve my issue.

bitmap_error

@jeevan9 can you create a repro? Or at the very least post what the code for MyIconButtonRenderer looks like? Though a repro would be more helpful

@jeevan9 Are you able to attach a small project demonstrating the issue? Thank you

I am also struck with the same crash, Please let me know if any solution

JniPeerMembers.AssertSelf
android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object.

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

The above crash happened randomly, Unfortunately, I can not re produce. But it is happened sporadically, Till not it was happened 11 times(As per hockey app report).

Closing as we've had no reproduction provided to date, with the original report being over two months ago. Please reopen with more information and a reproduction if the issue still occurs on 3.0/3.1-pre.

I am randomly getting this issue - can't see any custom renderer in the stack trace just platform stuff. Can you consider re-opening this.

image

Here is the full stack trace:

0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal C#
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException at /Users/builder/jenkins/workspace/xamarin-android-d15-7/xamarin-android/external/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122,4 C#
0x20 in object.51c2ddc7-9a76-4a85-8ca0-23e855bbaca6 C#
0x2E in Java.Interop.JniPeerMembers.AssertSelf C#
0x1 in Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractVoidMethod C#
0x12 in Android.Graphics.Bitmap.Recycle at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/obj/Release/android-26/mcw/Android.Graphics.Bitmap.cs:1084,5 C#
0xE in Xamarin.Forms.Platform.Android.ButtonDrawable.Reset at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:76,5 C#
0x14 in Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:108,5 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x17 in Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\ButtonBackgroundTracker.cs:122,6 C#
0x2 in Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\ButtonBackgroundTracker.cs:113,4 C#
0x5E in Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs:88,5 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x7B in Xamarin.Forms.Platform.Android.VisualElementRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:234,7 C#
0x13 in Xamarin.Forms.Platform.Android.PageRenderer.Dispose at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:33,4 C#
0x2 in Java.Lang.Object.Dispose at /Users/builder/data/lanes/5945/dffc5912/source/monodroid/external/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203,4 C#
0x42 in Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView at D:\agent_work\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:91,6 C#
0x8 in Android.Support.V4.App.Fragment.n_OnDestroyView C#
0x11 in object.51c2ddc7-9a76-4a85-8ca0-23e855bbaca6 C#

It's not easy to repro on demand without sharing my entire app source code which I can't do here.

I too am getting the same error, pretty consistently in my GooglePlay Pre-launch reports. With what I believe is an identical stack trace.

Annoying part is, when I try to reproduce the exact steps, as the test recording video, it does not crash for me :(

Here is a logcat trace.

06-20 09:18:58.228: I/MonoDroid(8313): UNHANDLED EXCEPTION:
06-20 09:18:58.236: I/MonoDroid(8313): System.ObjectDisposedException: Cannot access a disposed object.
06-20 09:18:58.236: I/MonoDroid(8313): Object name: 'Android.Graphics.Bitmap'.
06-20 09:18:58.236: I/MonoDroid(8313): at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) <0xd45006c8 + 0x00094> in :0
06-20 09:18:58.236: I/MonoDroid(8313): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) <0xd45008d0 + 0x0001f> in :0
06-20 09:18:58.236: I/MonoDroid(8313): at Android.Graphics.Bitmap.Recycle () <0xd463765c + 0x00043> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.ButtonDrawable.Reset () <0xd36a7f10 + 0x0001f> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose (System.Boolean disposing) <0xd36a8188 + 0x0001f> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose (System.Boolean disposing) <0xd369b0d8 + 0x0002b> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.236: I/MonoDroid(8313):
at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer.Dispose (System.Boolean disposing) <0xd36e0c6c + 0x000a7> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) <0xd36c60a0 + 0x00057> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () <0xd36de310 + 0x000d7> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.236: I/MonoDroid(8313): at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) <0xd35ea240 + 0x0003b> in <9c2ce072107e45b7aa18f455f52752ef>:0 06-20 09:18:58.236: I/MonoDroid(8313): at (wrapper dynamic-method) System.Object.96633450-9b55-41fc-8c86-b460f54a9319(intptr,intptr) 06-20 09:18:58.297: W/art(8313): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable 06-20 09:18:58.297: W/art(8313): --------- beginning of crash 06-20 09:18:58.304: E/AndroidRuntime(8313): FATAL EXCEPTION: ControllerMessenger 06-20 09:18:58.304: E/AndroidRuntime(8313): Process: com.*redacted app name*, PID: 8313 06-20 09:18:58.304: E/AndroidRuntime(8313): android.runtime.JavaProxyThrowable: System.ObjectDisposedException: Cannot access a disposed object. 06-20 09:18:58.304: E/AndroidRuntime(8313): Object name: 'Android.Graphics.Bitmap'. 06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) <0xd45006c8 + 0x00094> in <c491698b4f82475fbcdb4a36efdb78e8>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) <0xd45008d0 + 0x0001f> in <c491698b4f82475fbcdb4a36efdb78e8>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Android.Graphics.Bitmap.Recycle () <0xd463765c + 0x00043> in <7222dc8be58347a18dc46a0986ffad8d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.ButtonDrawable.Reset () <0xd36a7f10 + 0x0001f> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose (System.Boolean disposing) <0xd36a8188 + 0x0001f> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose (System.Boolean disposing) <0xd369b0d8 + 0x0002b> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer.Dispose (System.Boolean disposing) <0xd36e0c6c + 0x000a7> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a1 8dc46a0986ffad8d>:0 06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) <0xd36d04a0 + 0x0014b> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing) <0xd36c60a0 + 0x00057> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Java.Lang.Object.Dispose () <0xd46e68f0 + 0x0001b> in <7222dc8be58347a18dc46a0986ffad8d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView () <0xd36de310 + 0x000d7> in <6d4ed4125be34de781270a341e979c0d>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this) <0xd35ea240 + 0x0003b> in <9c2ce072107e45b7aa18f455f52752ef>:0
06-20 09:18:58.304: E/AndroidRuntime(8313): at (wrapper dynamic-method) System.Object.96633450-9b55-41fc-8c86-b460f54a9319(intptr,intptr)
06-20 09:18:58.304: E/AndroidRuntime(8313): at md58432a647068b097f9637064b8985a5e0.FragmentContainer.n_onDestroyView(Native Method)
06-20 09:18:58.304: E/AndroidRuntime(8313): at md58432a647068b097f9637064b8985a5e0.FragmentContainer.onDestroyView(FragmentContainer.java:41)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.Fragment.performDestroyView(Fragment.java:2497)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1503)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:792)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2590)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2377)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2332)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2239)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.os.Handler.handleCallback(Handler.java:751)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.os.Handler.dispatchMessage(Handler.java:95)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.base.Interrogator.a(Interrogator.java:19)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:142)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:134)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:34)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.MotionEvents.a(MotionEvents.java:74)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.MotionEvents.a(MotionEvents.java:52)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.Tap.c(Tap.java:9)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.Tap.a(Tap.java:19)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.Tap$1.b(Tap.java:2)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.ViewInteraction.a(ViewInteraction.java:78)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.ViewInteraction.a(ViewInteraction.java:94)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.support.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
06-20 09:18:58.304: E/AndroidRuntime(8313): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.os.Handler.handleCallback(Handler.java:751)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.os.Handler.dispatchMessage(Handler.java:95)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.os.Looper.loop(Looper.java:154)
06-20 09:18:58.304: E/AndroidRuntime(8313): at android.app.ActivityThread.main(ActivityThread.java:611
9)
06-20 09:18:58.304: E/AndroidRuntime(8313): at java.lang.reflect.Method.invoke(Native Method)
06-20 09:18:58.304: E/AndroidRuntime(8313): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
06-20 09:18:58.304: E/AndroidRuntime(8313): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
06-20 09:18:58.308: I/Process(8313): Sending signal. PID: 8313 SIG: 9
06-20 09:18:58.321: I/ActivityManager(1065): Killing 7301:com.google.android.gms.unstable/u0a18 (adj 906): empty #17
06-20 09:18:58.361: I/WindowManager(1065): WIN DEATH: Window{74cacf3 u0 com.redacted app name/md53351f89f55b5e184b441dc4be31ab70a.MainActivity}
06-20 09:18:58.361: D/GraphicsStats(1065): Buffer count: 4
06-20 09:18:58.361: D/ConnectivityService(1065): ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=15, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&VALIDATED&FOREGROUND] ], android.os.BinderProxy@44de9e5)
06-20 09:18:58.363: I/ActivityManager(1065): Process com.redacted app name (pid 8313) has died

Started to receive this issue with latest update of Xamarin Forms 3.1.0.583944

Fatal Exception: java.lang.Throwable: Cannot access a disposed object.
Object name: 'Android.Graphics.Bitmap'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)(filename unknown)
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)(filename unknown)
at Android.Graphics.Bitmap.Recycle ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonDrawable.Reset ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonDrawable.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose (System.Boolean disposing)(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonBackgroundTracker.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.ButtonRenderer.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown) at Java.Lang.Object.Dispose ()(filename unknown) at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown) at Java.Lang.Object.Dispose ()(filename unknown) at Xamarin.Forms.Platform.Android.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing)(filename unknown)
at Xamarin.Forms.Platform.Android.PageRenderer.Dispose (System.Boolean disposing)(filename unknown)
at JobseekerApp.Droid.Renderers.ReedContentPageRenderer.Dispose (System.Boolean disposing)(filename unknown)
at Java.Lang.Object.Dispose ()(filename unknown)
at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnDestroyView ()(filename unknown)
at Android.Support.V4.App.Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this)(filename unknown)

I also started getting this bug after updating to XF 3.1.0.697729. I can't post my project for reproduction since it's a closed source, but here's at least a call stack:

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Android.Graphics.Bitmap'.
JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self)
JniPeerMembers+JniInstanceMethods.InvokeAbstractVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
Bitmap.Recycle ()
ButtonDrawable.Reset () D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:98
ButtonDrawable.Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ButtonDrawable.cs:130
Object.Dispose ()
ButtonBackgroundTracker.Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\ButtonBackgroundTracker.cs:139
ButtonBackgroundTracker.Dispose () D:\a\1\s\Xamarin.Forms.Platform.Android\ButtonBackgroundTracker.cs:130
ButtonRenderer.Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs:91
Object.Dispose ()
VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:237 Object.Dispose () VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:237
PageRenderer.Dispose (System.Boolean disposing) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\PageRenderer.cs:33
Object.Dispose ()
FragmentContainer.OnDestroyView () D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:74
Fragment.n_OnDestroyView (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) System.Object.46(intptr,intptr)

@pluggy this should be resolved in the latest 3.2 release

Add in list view this parameter:
<ListView CachingStrategy="RecycleElement">

Good luck!

Was this page helpful?
0 / 5 - 0 ratings