rotorgames / Rg.Plugins.Popup

Xamarin Forms popup plugin
MIT License
1.15k stars 337 forks source link

Xamarin.iOS 15.0 on real device "Cannot access a disposed object. Object name: 'PopupPageRenderer'." #697

Closed Phenek closed 2 years ago

Phenek commented 2 years ago

Hello,

🐛 Bug Report

After updating Xamarin.iOS 15.0, I got an exception "Cannot access a disposed object. Object name: 'PopupPageRenderer'." when interacting with a Rg.popup.Page, on my Iphone X (iOS 14)

I don't have this exception on simulator running IOS 15

  at Foundation.NSObject.get_SuperHandle () [0x00023] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:542 
  at UIKit.UIViewController.ViewDidLayoutSubviews () [0x00023] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:1143 
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLayoutSubviews () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:176 
  at Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.ViewDidLayoutSubviews () [0x00000] in C:\Users\mhvdi\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Platforms\Ios\Renderers\PopupPageRenderer.cs:112 
  at Rg.Plugins.Popup.IOS.Renderers.PopupPageRenderer.KeyBoardUpNotification (Foundation.NSNotification notifi) [0x0000c] in C:\Users\mhvdi\Documents\OpenSource\Rg.Plugins.Popup\Rg.Plugins.Popup\Platforms\Ios\Renderers\PopupPageRenderer.cs:136 
  at Foundation.InternalNSNotificationHandler.Post (Foundation.NSNotification s) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSNotificationCenter.cs:48 

Expected behavior

The PopupPagerenderer should not be dispose.

Reproduction steps

You can try to repoduce it when interacting with an Entry inside a RG.Popup.Page, on an Iphone with iOS 14 and App builded with Xamarin.iOS 15

Configuration

Platform:

Thanks for your good repository!

LuckyDucko commented 2 years ago

@Phenek does this include iOS 14.5 as well? or strictly iOS 14?

Phenek commented 2 years ago

@LuckyDucko iOS 14.5.1 has the issue.

Phenek commented 2 years ago

This happen when the keyboard want to show up Hope it can help

Phenek commented 2 years ago

I added the repo as reference, and found out that the renderer is disposed when the MainPage changed. But it should not be disposed at this time.

Commenting the dispose function give me a workaround. (ligne 41 of PopupPageRenderer.cs)

        protected override void Dispose(bool disposing)
        {
            //if (disposing)
            //{
            //    View?.RemoveGestureRecognizer(_tapGestureRecognizer);
            //}

            //base.Dispose(disposing);

            //_isDisposed = true;
        }

But I did not find a real explanation, and how to fix it properly.

LuckyDucko commented 2 years ago

@Phenek sorry I have been working on the MAUI extension.

I currently test using an iOS 14.5 device with this repo and haven't run into any issues, can you provide a sample repo?

Phenek commented 2 years ago

Ok let me try to explain my issue. (I got a fixe at the end :)

Hope it can be enough for you, or should I create a little project to reproduce the error?

Phenek commented 2 years ago

Update: This is affecting all real devices (iOS 14,15..) when App is compiled with Xamarin.iOS 15.0 No issue occur in simulator.