[BUG] System.ObjectDisposedException: Cannot access a disposed object.
Closed this issue · 7 comments
On Android I get this exception with the latest version:
[AppCenterCrashes] System.ObjectDisposedException: Cannot access a disposed object.
[AppCenterCrashes] Object name: 'Google.Android.Material.BottomNavigation.BottomNavigationView'.
[AppCenterCrashes] at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <b781c92013fd40caadc5fea1382cb1f8>:0
[AppCenterCrashes] at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <b781c92013fd40caadc5fea1382cb1f8>:0
[AppCenterCrashes] at Android.Views.ViewGroup.GetChildAt (System.Int32 index) [0x00018] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-31/mcw/Android.Views.ViewGroup.cs:3078
[AppCenterCrashes] at Xam.Shell.Badge.Droid.Renderers.BadgeShellItemRenderer.ApplyBadge (System.Int32 itemId, System.String badgeText, Xamarin.Forms.Color badgeBg, Xamarin.Forms.Color textColor) [0x00000] in <4ecbac75c65b42dfb3cc24db9c049988>:0
[AppCenterCrashes] at Xam.Shell.Badge.Droid.Renderers.BadgeShellItemRenderer.UpdateBadge (Xamarin.Forms.ShellSection item) [0x00027] in <4ecbac75c65b42dfb3cc24db9c049988>:0
[AppCenterCrashes] at Xam.Shell.Badge.Droid.Renderers.BadgeShellItemRenderer.InitBadges () [0x00016] in <4ecbac75c65b42dfb3cc24db9c049988>:0
[AppCenterCrashes] at Xamarin.Forms.Device+<>c__DisplayClass43_0.<InvokeOnMainThreadAsync>g__wrapAction|0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:130
[AppCenterCrashes] at Xamarin.Forms.Device+<>c__DisplayClass42_0`1[T].<InvokeOnMainThreadAsync>b__0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:116
[AppCenterCrashes] --- End of stack trace from previous location where exception was thrown ---
Which looks very much like:
xamarin/Xamarin.Forms#8145
Hello. I was not able to reproduce it, even with instructions mentioned in this comment. Could you please provide a sample project and additional information on whether you're using Android emulator for this and if yes, please leave a name of the device and OS API version.
I've added null-check in the recent #30 PR, but it may not be enough as i'm not able to reproduce it.
I added a try catch around the body of ApplyBadge and that at least seems to help android not to crash. I tried to see if I can solve the issue but haven't been able to till now.
I will try to make a sample project. Thanks.
I created a sample project and guess what... it works... But I won't rest until I can reproduce or solve the issue. Will let you know.
Hello, @jtorvald, no problem, i'm here if any help is needed...
Hello, @jtorvald, do you have any update on this issue? Were you able to consistently reproduce this under your sample project with the latest Nuget package?
@SnowPowerCore Hi thanks for following up. No, I have to give up. Also in my own project the exception disappeared and I don't know why. I will create a new issue when it happens again and if I'm able to reproduce it. Maybe it was just a Xamarin glitch.