rotorgames / Rg.Plugins.Popup

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

PlatformExtension.GetOrCreateRenderer - System.ArgumentNullException - Crash on Android #691

Open BurkusCat opened 3 years ago

BurkusCat commented 3 years ago

🐛 Bug Report

Crashes are happening for PopupNavigationImpl.AddAsync and PopupNavigationImpl.RemoveAsync (this one is most common). I am using Prism.Plugin.Popups and tried originally posting this on that repo: https://github.com/dansiegel/Prism.Plugin.Popups/issues/238 The maintainers of that repo advised it makes more sense to be posted here.

From popup pages, I am using absolute navigation to move to another page + close the popup e.g.:

// example 1
await navigationService.NavigateAsync($"/{nameof(LoginPage)}");

// example 2         
await navigationService.NavigateAsync($"/{nameof(MainPage)}");

This is how we open popups in our view models:

// example 1
await navigationService.NavigateAsync(nameof(AccountLogoutCheckPopupPage));

// example 2
await navigationService.NavigateAsync($"{nameof(LoginSuccessPopupPage)}");

I can see reports in app center from 20~ users on Android devices 5, 6, 9, 10, and 11. Most reports are from 9, 10, and 11 but most people using our app are on these devices. For some users, the crash happens immediately after some navigation. For some users, the crash might happen 20 minutes after last app center event (app crashes in the background?).

The crashes are somewhat rare but it would be good to track down what is causing the instability. I've not been able to reproduce the error myself, I can only see the crash reports on app center.

Expected behavior

No crashes

Reproduction steps

I cannot reproduce but this is the full error log: Full error:

PlatformExtension.GetOrCreateRenderer (Xamarin.Forms.VisualElement bindable)

System.ArgumentNullException: Value cannot be null. Parameter name: obj

Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj, System.Object[] args)
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context)
Platform.CreateRendererWithContext (Xamarin.Forms.VisualElement element, Android.Content.Context context)
PlatformExtension.GetOrCreateRenderer (Xamarin.Forms.VisualElement bindable)
PopupPlatformDroid.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl.RemoveAsync (Rg.Plugins.Popup.Pages.PopupPage page)
PopupNavigationImpl+<>c__DisplayClass23_0.<RemovePageAsync>b__0 ()
PopupNavigationImpl+<>c__DisplayClass28_0.<InvokeThreadSafe>b__0 ()
PopupNavigationImpl.OnInitialized (System.Object sender, System.EventArgs e)
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state)
SyncContext+<>c__DisplayClass2_0.<Post>b__0 ()
Thread+RunnableImplementor.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.86(intptr,intptr)

Configuration

Version: 2.0.0.11? Using Prism.Plugin.Popups 8.0.76

Platform:

LuckyDucko commented 3 years ago

This is something we have had running for a while #599

It seems nobody can reproduce, however reports from appcenter keeps rolling in.