Overview
I have code that employs PopModalAsync and using Xamarin Forms v2.3.4.270 the app does NOT crash with iOS 8.1
If I take that same code and upgrade to the latest Xamarin Forms then the app DOES crash with iOS 8.1 but does not crash with iOS 12.x
Three Possible Conclusions
- My code has a defect
- Xamarin Forms has a regression defect
- iOS 8.1 Simulator has a defect (unfortunately I do not have the iOS 8.1 hardware)
My Ask
- Before I open a bug report I would like to get a review of my code.
- If Xamarin Forms has a defect are there thoughts on work-arounds. I guess the easiest workaround is to not support iOS 8.1
The Code
I placed two solutions in https://github.com/Paul-GolfingScribe/PopModalAsyncRegressionDefect
- ToolbarPopBug - uses Xamarin Forms v2.3.4.270 and there is no crash on iOS 8.1
- ToolbarPopBug2Crash - uses Xamarin Forms v3.3.0.967583 and throws ObjectDisposedException on iOS 8.1 but does not with iOS 12.x
I provided the two solutions to alleviate the TaskAsync issues while changing Package versions.
Here is the Class that is causing my grief:
public class GolferPage : ContentPage
{
public GolferPage()
{
Label label = new Label();
label.Text = "Using either Done button causes a crash in iOS 8.1, but not in the latest iOS. " +
"However using Xamarin Forms v2.3.4.270 will NOT cause a crash.";
Button buttonDone = new Button();
buttonDone.Text = "Done";
buttonDone.Clicked += async (sender, e) => await DoneAsync();
AddDoneButton();
StackLayout stackLayout = new StackLayout
{
VerticalOptions = LayoutOptions.StartAndExpand,
Padding = new Thickness(20),
Children = {
label,
buttonDone
}
};
Content = new ScrollView
{
Content = stackLayout
};
}
public void AddDoneButton()
{
var btnDone = new ToolbarItem
{
Text = "Done",
Priority = 0
};
btnDone.Clicked += async (sender, e) => await DoneAsync();
ToolbarItems.Add(btnDone);
}
protected async Task<Page> DoneAsync()
{
return await Navigation.PopModalAsync();
}
}
Thanks in advance for your time, Paul