Rg.Plugins.Popup: System.NullReferenceException When trying to pop a popup
Hi,
🐛 Bug Report
On iOS 15, sometimes we got this exception when we try to pop a specific popup:
`Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Rg.Plugins.Popup.IOS.Impl.PopupPlatformIos.AddAsync (Rg.Plugins.Popup.Pages.PopupPage page) <0x105f87294 + 0x00460> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl.AddAsync (Rg.Plugins.Popup.Pages.PopupPage page) <0x105f897e8 + 0x0003f> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>c__DisplayClass20_0.<PushAsync>b__0 () <0x105f90804 + 0x0007b> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>c__DisplayClass28_0.<InvokeThreadSafe>b__0 () <0x105f82440 + 0x0018b> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>c__DisplayClass23_0.<RemovePageAsync>b__0 () <0x105f81c90 + 0x001e7> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0 at Rg.Plugins.Popup.Services.PopupNavigationImpl+<>c__DisplayClass28_0.<InvokeThreadSafe>b__0 () <0x105f82440 + 0x0018b> in <c764561bc21b420689a747c209523bf2#9d0a4ec250688d50b764561a6d88ab00>:0
Note we call “RemovePageAsync” and we got an exception from the “AddAsync” method.
Expected behavior
Pop the specific popup.
Configuration
Version: 2.0.0.13
Platform:
- iPhone 11 Pro Max iOS 15.0.1
 - Xamarin.iOS 14.20.0.3
 
Thanks.
About this issue
- Original URL
 - State: open
 - Created 3 years ago
 - Reactions: 2
 - Comments: 62 (11 by maintainers)
 
Just here to say this bug is not reproducing any more with the latest version
Having this issue on our production app on iOS devices 15+ massively. Turns out I have similar crashes in the code that references
UIApplication.SharedApplication.KeyWindowI have the same issue on my iOS 15+ device, but it is a race condition. If I click a button that will show a pop-up, right when the app started, then the
KeyWindowisnulland throws the exception. If I wait a few seconds longer, then it won’t happen as theKeyWindowis known then.Its unusual how some production apps are having issues and some arent.
I haven’t noticed any production issues on any of my iOS 15 devices, however lets hope this sorts out this slippery issue
I’ll try it tonight