Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Crach after back to previous view #120

Open
PrzemekZA opened this issue Nov 29, 2022 · 4 comments
Open

iOS Crach after back to previous view #120

PrzemekZA opened this issue Nov 29, 2022 · 4 comments

Comments

@PrzemekZA
Copy link

Describe the bug
App crash when back to previous view from view where banner is.

{System.NullReferenceException: Object reference not set to an instance of an object
  at MarcTron.Plugin.Renderers.AdViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs'1[TElement] e) [0x00075] in <518e4ffda48f4eb1896acaa8d2c1eb18>:0 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer'1[TElement].SetElement (TElement element) [0x0017a] in <95d1c404699e420c91deaf9742b39577>:0 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer'1[TElement].Dispose (System.Boolean disposing) [0x0008c] in <95d1c404699e420c91deaf9742b39577>:0 
  at Xamarin.Forms.Platform.iOS.ViewRenderer'2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in <95d1c404699e420c91deaf9742b39577>:0 
  at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/Foundation/NSObject2.cs:227 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:91 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:41 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer'1[TElement].Dispose (System.Boolean disposing) [0x00058] in <95d1c404699e420c91deaf9742b39577>:0 
  at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/Foundation/NSObject2.cs:227 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:91 
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:41 
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer'1[TElement].Dispose (System.Boolean disposing) [0x00058] in <95d1c404699e420c91deaf9742b39577>:0 
  at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/Foundation/NSObject2.cs:227 
  at Xamarin.Forms.Platform.iOS.DisposeHelpers.DisposeModalAndChildRenderers (Xamarin.Forms.Element view) [0x00042] in D:\a\1\s\Xamarin.Forms.Platform.iOS\DisposeHelpers.cs:23 
  at Xamarin.Forms.Platform.iOS.Platform.HandleChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x00006] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:371 
  at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:593 
  at Xamarin.Forms.Element.OnDescendantRemoved (Xamarin.Forms.Element child) [0x00018] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:594 
  at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00027] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:348 
  at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:850 
  at Xamarin.Forms.Page.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0003b] in D:\a\1\s\Xamarin.Forms.Core\Page.cs:498 
  at System.Collections.ObjectModel.ObservableCollection'1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in <504c0d7e7072450ba814667235f35ffa>:0 
  at System.Collections.ObjectModel.ObservableCollection'1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00009] in <504c0d7e7072450ba814667235f35ffa>:0 
  at System.Collections.ObjectModel.ObservableCollection'1[T].RemoveItem (System.Int32 index) [0x00021] in <504c0d7e7072450ba814667235f35ffa>:0 
  at System.Collections.ObjectModel.Collection'1[T].Remove (T item) [0x00027] in <f816f9a78b7342b49735899bb960e7b6>:0 
  at Xamarin.Forms.NavigationPage.Xamarin.Forms.INavigationPageController.RemoveAsyncInner (Xamarin.Forms.Page page, System.Boolean animated, System.Boolean fast) [0x000e7] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:362 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.UpdateFormsInnerNavigation (Xamarin.Forms.Page pageBeingRemoved) [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:844 
  at Xamarin.Forms.Platform.iOS.NavigationRenderer+ParentingViewController.DidMoveToParentViewController (UIKit.UIViewController parent) [0x0003a] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:1504 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_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 /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/Foundation/NSAction.cs:178 
  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:57 
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:92

To Reproduce
Steps to reproduce the behavior:

  1. Go to view where banner is visable.
  2. Click Back
  3. App crash

Expected behavior
App will not crash

Smartphone (please complete the following information):

  • Device: iPhone8
  • OS: iOS 15.7

Additional context
Issue is on plugin version 1.9.0.2
In previous versions of the plugin it was fine

@PrzemekZA
Copy link
Author

PrzemekZA commented Nov 29, 2022

App is crashing when NavigationPage is used.
Sample: https://github.com/PrzemekZA/AdMobTest

@PrzemekZA
Copy link
Author

Solution: create ViewRender with code

protected override void OnElementChanged(ElementChangedEventArgs<MTAdView> e)
        {
            if (e.NewElement == null)
                return;

            base.OnElementChanged(e);
        }

@marcojak
Copy link
Owner

marcojak commented Dec 3, 2022

Thank you.
I've found the issue with the code and I'll release a new version that will fix it.

@ice-lenor
Copy link

Hello @marcojak! I wonder if you managed to take a look at this bug yet? No pressure, holidays and all, just wondering :).
Please let me know if you need any help testing.
Thank you for the wonderful plugin and Happy Holidays!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants