mg-code-solutions / MgAdmob

Utilise Google Admob Ads (banners, interstitial, and rewarded videos) in your Xamarin Projects (Android and iOS)
MIT License
4 stars 1 forks source link

iOS app crash during navigation to/from page with banner ads #2

Open eliseiml opened 2 years ago

eliseiml commented 2 years ago

Describe the bug Hi! Thanks for the plugin. It helped me to solve some problems which I had with MTAdMobs plugin. But there is another issue which is critical for me. When I'm navigating to (or from) a page with ListView with a banner ad inside - app crashes. Android works fine.

I'm using latest version of the plugin (0.0.2), Xamarin.Forms (5.0.0.2401), Xamarin.Google.iOS.MobileAds (8.13.0).

I would be grateful if you can solve this asap or tell me what am I doing wrong please.

Here is the full stack trace:

System.ObjectDisposedException: Cannot access a disposed object. Object name: Google.MobileAds.BannerView. at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:40 at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:35 at UIKit.UIView.AddSubview (UIKit.UIView view) [0x00005] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/UIKit/UIView.g.cs:243 at Xamarin.Forms.Platform.iOS.ViewRenderer 2[TView,TNativeView].SetNativeControl (TNativeView uiview) [0x00047] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:244 at Plugin.MgAdmob.Renderers.MgBannerAdViewRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0008d] in :0 at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:266 at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:362 at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle, System.Boolean checkAccess) [0x000f8] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:90 at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\BindableObject.cs:38 at Xamarin.Forms.Platform.iOS.VisualElementRenderer 1[TElement].Dispose (System.Boolean disposing) [0x00077] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:396 at Xamarin.Forms.Platform.iOS.ViewRenderer 2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:124 at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSObject2.cs:218 at Xamarin.Forms.Platform.iOS.DisposeHelpers.DisposeModalAndChildRenderers (Xamarin.Forms.Element view) [0x000a0] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\DisposeHelpers.cs:41 at Xamarin.Forms.Platform.iOS.Platform.HandleChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00006] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:371 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:593 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:594 at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00027] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:348 at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\VisualElement.cs:847 at Xamarin.Forms.ItemsView.RemoveLogicalChild (Xamarin.Forms.Element element) [0x00034] in D:\a_work\1\s\Xamarin.Forms.Core\Items\ItemsView.cs:119 at Xamarin.Forms.Platform.iOS.TemplatedCell.Bind (Xamarin.Forms.DataTemplate template, System.Object bindingContext, Xamarin.Forms.ItemsView itemsView) [0x00044] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\TemplatedCell.cs:108 at Xamarin.Forms.Platform.iOS.ItemsViewController 1[TItemsView].UpdateTemplatedCell (Xamarin.Forms.Platform.iOS.TemplatedCell cell, Foundation.NSIndexPath indexPath) [0x0007b] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:287 at Xamarin.Forms.Platform.iOS.ItemsViewController 1[TItemsView].GetCell (UIKit.UICollectionView collectionView, Foundation.NSIndexPath indexPath) [0x00033] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewController.cs:94 at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(intptr,intptr,intptr) at UIKit.UICollectionView.InsertItems (Foundation.NSIndexPath[] indexPaths) [0x00021] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/UIKit/UICollectionView.g.cs:463 at Xamarin.Forms.Platform.iOS.ObservableItemsSource+<>cDisplayClass36_0.b__0 () [0x00000] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:166 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Update (System.Action update, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00015] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:278 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x0005a] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:166 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00047] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:121 at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x0002d] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:108 at System.Collections.ObjectModel.ObservableCollection 1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 at System.Collections.ObjectModel.ObservableCollection 1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 at System.Collections.ObjectModel.ObservableCollection 1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196 at System.Collections.ObjectModel.Collection 1[T].Insert (System.Int32 index, T item) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:116 at Pancakes.PageModels.EventsListPageModel.InsertAds () [0x00038] in /Users/administrator/source/Pancakes-Xamarin-Forms/Pancakes/Pancakes/PageModels/EventsListPageModel.cs:71 at Pancakes.PageModels.EventsListPageModel.Init (System.Object initData) [0x001b0] in /Users/administrator/source/Pancakes-Xamarin-Forms/Pancakes/Pancakes/PageModels/EventsListPageModel.cs:50 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSAction.cs:178 --- End of stack trace from previous location where exception was thrown --- at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:75 at Pancakes.iOS.Application.Main (System.String[] args) [0x00001] in /Users/administrator/source/Pancakes-Xamarin-Forms/Pancakes/Pancakes.iOS/Main.cs:12

Thank you.

mg-code-solutions commented 2 years ago

@eliseiml Thank you for the report. I am current doing some contract work but I will take a look ASAP