xabre / xamarin-forms-tab-badge

Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
MIT License
307 stars 75 forks source link

Cannot access a disposed object. Object name: 'BadgedTabbedPageRenderer'. #66

Closed RajdeepSharma1911 closed 5 years ago

RajdeepSharma1911 commented 5 years ago

I have a tabbed page as Home Screen. Where I m displaying badge. When I logout the user and login again to come to home view. This error crashes the App in iOS.

xabre commented 5 years ago

@RajdeepSharma1911 please test with the latest stable release 2.1.2. Reopen if it's still the case. Also attach a crashlog with a stacktrace.

uksreejith commented 5 years ago

@xabre Facing the same issue. Please check the following log :

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'BadgedTabbedPageRenderer'. at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/Foundation/NSObject2.cs:456 at UIKit.UITabBarController.get_TabBar () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UITabBarController.g.cs:361 at Plugin.Badge.iOS.BadgedTabbedPageRenderer.CheckValidTabIndex (Xamarin.Forms.Page page, System.Int32& tabIndex) [0x0003d] in <47ebadfd70e04d73b889d06fc57bf943>:0 at Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00022] in <47ebadfd70e04d73b889d06fc57bf943>:0 at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChanged EventArgs(object,System.ComponentModel.PropertyChangedEventArgs) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:173 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:339 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:622 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:422 at Xamarin.Forms.BindingExpression.ApplyCor e (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00220] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:167 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:57 at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:618 at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/Foundation/NSAction.cs:152 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[ ] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UIApplication.cs:63 at AlghanimMobile.iOS.Application.Main (System.String[] args) [0x00007] in D:\AlghanimEnggMobileApp\AlghanimMobile\AlghanimMobile.iOS\Main.cs:18 Thread started: #37 2019-05-21 16:24:55.221 AlghanimMobile.iOS[383:92644] Unhandled managed exception: Cannot access a disposed object. Object name: 'BadgedTabbedPageRenderer'. (System.ObjectDisposedException) at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/Foundation/NSObject2.cs:456 at UIKit.UITabBarController.get_TabBar () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UITabBarController.g.cs:361 at Plugin.Badge.iOS.BadgedTabbedPageRenderer.CheckValidTabIndex (Xamarin.Forms.Page page, System.Int32& tabIndex) [0x0003d] in <47ebadfd70e04d73b889d06fc57bf943>:0 at Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00022] in <47ebadfd70e04d73b889d06fc57bf943>:0 at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArg s) at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:173 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:339 at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:622 at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:422 at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject ta rget, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00220] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:167 at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:57 at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__49_0 () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:618 at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/Foundation/NSAction.cs:152 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UIApplication.cs:79 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delega teClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.16/src/Xamarin.iOS/UIKit/UIApplication.cs:63 at AlghanimMobile.iOS.Application.Main (System.String[] args) [0x00007] in D:\AlghanimEnggMobileApp\AlghanimMobile\AlghanimMobile.iOS\Main.cs:18

mgoodfellow commented 5 years ago

I'm suffering the same issue but only affecting Android it seems:

TabbedPageRenderer.OnDetachedFromWindow ()
View.n_OnDetachedFromWindow (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.51(intptr,intptr)
uksreejith commented 5 years ago

I created a new custom renderer and copy pasted the renderer code from this project into my android project. Somehow its working after that. I have no idea how..😛😂 My original intention was to try an debug the renderer. But was not able to reproduce this bug.