Native stack trace of crash:
DEBUG|8/5/2019 8:19:53 PM|App: Failed to init Home View|EX:Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[Xamarin_Forms_Platform_iOS_PlatformRenderer setNeedsUpdateOfHomeIndicatorAutoHidden]: unrecognized selector sent to instance 0x104f8bea0
This issue is due to adding functionality in XF 4.0 to support hiding the home indicator on iPhone X/Xs/Xr devices, as per:
https://github.com/xamarin/Xamarin.Forms/pull/5717
It would seem that on some devices that run iOS 11 that do not have a home indicator, i.e. any iPhone with a home button, do not have the setNeedsUpdateOfHomeIndicatorAutoHidden selector, so when XF calls:
if (Forms.IsiOS11OrNewer)
SetNeedsUpdateOfHomeIndicatorAutoHidden();
on a phone running iOS 11 that does not support the home indicator, then the crash occurs.
An easy and seemingly harmless fix would be to check that the calling object responds to that selector, so instead of the above version check do the following selector check:
if (this.RespondsToSelector(new ObjCRuntime.Selector("setNeedsUpdateOfHomeIndicatorAutoHidden")))
SetNeedsUpdateOfHomeIndicatorAutoHidden();
I also found anther report of the same issue where the fix was to do the resondsToSelector check:
https://github.com/lionheart/openradar-mirror/issues/18762
These are all of the places in XF source code that call that method that I found with a search:
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/PlatformRenderer.cs#L94
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/ModalWrapper.cs#L107
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs#L193
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/PageRenderer.cs#L528
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/PhoneMasterDetailRenderer.cs#L342
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs#L234
I cannot reproduce since I do not have an iPhone 6 running iOS 11 (or any other < iPhone X device running iOS 11). Issue does not reproduce on simulators.
We've just uplifted our Xamarin libraries to 4.x. We are able to recreate this on a physical device running 11.0. This negatively impacts our release as we have customers running the affected OS version. An urgent fix is needed and much appreciated!
@StinkyTowel a PR is in the works, please follow the progress in #7114. This is going to be in 4.0, 4.1 and 4.2 which all have frequent releases so it should hopefully be resolved soon.
Thanks!
@jfversluis Will follow the PR. Thanks for the quick response!
Old PR closed. Started three new PRs, one for each branch 4.0, 4.1, and 4.2:
4.0: https://github.com/xamarin/Xamarin.Forms/pull/7151
4.1: https://github.com/xamarin/Xamarin.Forms/pull/7149
4.2: https://github.com/xamarin/Xamarin.Forms/pull/7150
closed by #7151