Created attachment 25073 [details]
The output for when the bug occurs
I have found an issue where if you have a picker within an Android app, that has AppCompat enabled and has custom renderer inheriting from Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer, when you tap the picker very rapidly multiple times and after each tap you tap outside the picker (in order to close it), the app crashes after several clicks to open-close the picker.
The steps are very fast, but are as follows: click on the picker in order to open it, after that very fast click outside the picker. Repeat multiple times.
This is a possible duplicate/regression of #41717.
I have attached the output, which tells me that there is a null reference exception causing the app to crashes. The cause of this is in line 115 from PickerRenderer for AppCompat.
Here is the line: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs#L115
I guess that at some point before closing/opening the next picker, the dialog becomes null, even after all of the checks.
When we look at the git blame, we can see this:
This was the fix for 41717 that was released with 2.4.
Unfortunately, I can't confirm that this was an issue before the 2.4 release.
A sample of my picker renderer:
using PickerRenderer = Xamarin.Forms.Platform.Android.AppCompat.PickerRenderer;
[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))]
public class MyPickerRenderer : PickerRenderer
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
if (e.OldElement == null && Element is MyPicker pickerElement)
// Change fontSize and placeholderFontSize
What sort of device are you testing this on (for speed, I assume you're using a device) and do you have a more complete project to upload for debugging? I cannot seem to reproduce this despite rather quickly tapping in and out of the Picker on an S8 device.
Sorry for missing this - this happened on my HTC 10 running Android 7.0 and also on Samsung Galaxy S6 Edge running 7.0.
Unfortunately, I cannot upload a sample project, but I will try my best to describe the workflow that we have:
1) We are opening a certain page;
2) In the ctor we create an instance of our binded viewModel;
3) In the viewModel's ctor we start loading the data to the picker. The data is being loaded asynchronously via GET request. The request is not being awaited;
4) The picker is being binded to an ObservableCollection of other viewModels. When we get the result from our request, we simply set the result to the collection.
NOTE: Opening the picker doesn't initiate another GET request.
To the reporter or anyone else experiencing the issue, reopen this when we can get a reproduction project to help us investigate further. Thanks.