xabre/xamarin-forms-tab-badge

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

Closed this issue · 5 comments

Hi there,

After opening our app in the morning, the app crashed and it was related to badge so I report it here in case it might be useful.

The error was :

Cannot access a disposed object. Object name: 'BadgedTabbedPageRenderer'. @ iPad / 10.3.2 - : 
  at Foundation.NSObject.get_SuperHandle () <0x100a40140 + 0x000b0> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0 
  at UIKit.UITabBarController.get_TabBar () <0x100a689f0 + 0x00063> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0 
  at Plugin.Badge.iOS.BadgedTabbedPageRenderer.CheckValidTabIndex (Xamarin.Forms.Page page, System.Int32& tabIndex) <0x100e915d0 + 0x000af> in <afd8d9140eb740e59aa7f10157bc6de8#c1a6cf1187f05726b69010dae51380db>:0 
  at Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0x100e91340 + 0x000a3> in <afd8d9140eb740e59aa7f10157bc6de8#c1a6cf1187f05726b69010dae51380db>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) <0x100802960 + 0x00063> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) <0x10087dff0 + 0x00023> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) <0x100804460 + 0x00223> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) <0x100803720 + 0x00393> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) <0x1008098b0 + 0x005a3> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) <0x1008095c0 + 0x0008f> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () <0x10080bde0 + 0x00023> in <0f1ce60dbc6b4e24af01294c7acf41c6#c1a6cf1187f05726b69010dae51380db>:0 
  at Foundation.NSAsyncActionDispatcher.Apply () <0x100a3c540 + 0x00023> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (intstring[]intptrintptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) <0x100a548e0 + 0x0002b> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x100a54820 + 0x000ab> in <58a9bd8a3cbb4d0092bc0a767ff66c0f#c1a6cf1187f05726b69010dae51380db>:0 
  at Application.Main (System.String[] args) <0x1000319a0 + 0x001d7> in <22a26e2050ea498e9e0ddc60907a8be2#c1a6cf1187f05726b69010dae51380db>:0 

xabre commented

Hi @pboisso, can you describe your scenario more in detail. Maybe some reproduction steps? Would help a lot :)

Hi @xabre

This is a little tricky, but there is what I think happen...

  1. We create a tab page with badges binded on the pageview model
  2. After some user actions, we need to reload another tab page so we do with a new tabpage, etc.
  3. Our app received updates on background threads that updates the old viewmodel
  4. I think the bindings are somehow re-triggered (VM still living?), but the old tabpage has been disposed?

We were not seeing any similar error before installing the badge component.

I hope this may help...

Thanks a lot for the great component, very useful !

xabre commented

Hi @pboisso i've attempted a fix in v 1.1.3. Maybe you can check it out an let me know :) Thanks

Will do and keep you posted. Thanks !!!

This fixed the issue for me FYI.

Thank you!