У меня есть мобильное приложение Xamarin Forms , которое содержит Webview .Содержимое Webview представляет собой динамически генерируемый HTML.На самом деле это вопросник, который мы генерируем для каждого клиента, в результате чего вопросы будут разными.Вот почему мы использовали Webview , поскольку он позволяет нам генерировать динамический HTML для каждого клиента.
Вот XAML для Webview (упрощенно для ясности).
<ContentPage.Content>
<StackLayout>
<!-- WebView needs to be given height and width request within layouts to render. -->
<WebView x:Name="WebView" WidthRequest="1000" HeightRequest="1000" />
</StackLayout>
</ContentPage.Content>
Вот код в код Xamarin Form , который заполняет Webview (упрощенный для ясности).
protected override async void OnAppearing()
{
base.OnAppearing();
WebView.IsVisible = false;
var questionnaire = await InspectionView.GetVehicleInspection();
this._vehicleInspection = questionnaire;
StringBuilder htmlString = new StringBuilder();
string generatedHtml = new VehicleInspectionServices().GenerateHtmlFromVehicleInspection(questionnaire);
htmlString.Append(generatedHtml);
var htmlWebView = new HtmlWebViewSource { Html = htmlString.ToString() };
WebView.Source = htmlWebView;
WebView.IsVisible = true;
}
Вот фрагмент результирующего HTMLэто генерируется и отображается в Webview .
<html>
<head>
<link rel=stylesheet href=https://myazurestorage.blob.core.windows.net/myblobname/styles.css\>
</head>
<body>
<div>
<h2>Internal</h2>
<h3>Is the interior clean?</h3>
<input id=radio30216 type=radio name=radiobuttons100068 value=30216</input>
<label for=radio30216>Clean</label><input id=radio30217 type=radio name=radiobuttons100068 value=30217</input>
<label for=radio30217>Ok</label><input id=radio30218 type=radio name=radiobuttons100068 value=30218</input>
<label for=radio30218>Unclean</label>
<hr>
<h3>Are seat belts working?</h3>
<input id=radio30219 type=radio name=radiobuttons100069 value=30219</input>
<label for=radio30219>Yes</label><input id=radio30220 type=radio name=radiobuttons100069 value=30220</input>
<label for=radio30220>No</label><hr>
<h3>Are there any warning lights on the dashboard?</h3>
<input id=radio30221 type=radio name=radiobuttons100070 value=30221</input>
<label for=radio30221>Yes</label>
<input id=radio30222 type=radio name=radiobuttons100070 value=30222</input>
<label for=radio30222>No</label>
<hr>
<h3>If yes please provide information</h3>
<input type=text id=text100071></input>
<hr>
<h2>External</h2>
<h3>Are there and dents or scratches on the bodywork?</h3>
<input id=radio30232 type=radio name=radiobuttons100075 value=30232</input>
<label for=radio30232>Yes</label><input id=radio30233 type=radio name=radiobuttons100075 value=30233</input>
<label for=radio30233>No</label>
</div>
</body>
</html>
Это довольно стандартный HTML (как и было задумано).
На устройствах Android Webview очень прочный и ни разу не падал.Однако на устройствах Apple (iPhone / iPad) приложение иногда неожиданно закрывается.Обычно, когда пользователь прокручивает Webview и заполняет вопросы.Это очень непредсказуемо.Это работает на некоторых устройствах, но не на других.Диагностировать проблему очень сложно.
Кто-нибудь еще видел подобное поведение при использовании Webview ?Любые предложения относительно того, почему это внезапно закрывается, и только на устройствах Apple?
ОБНОВЛЕНИЕ
Мы видели проблему на следующих устройствах.
- iPhone 8 под управлением iOS 12.1
- iPhone8 Plus под управлением iOS 12.1.4
- iPhone 8 под управлением iOS 12.1.4
- iPad Mini 2 под управлением iOS 11.1.2
Ниже приведен пример ошибки.работает Visual Studio 2017 15.9.4 (усечено, поскольку фактическая ошибка была очень продолжительной)
2019-03-01 09:28:07.857 IFMDriverServicesiOS[274:5768] critical: Stacktrace:
2019-03-01 09:28:07.857 IFMDriverServicesiOS[274:5768] critical: at <unknown> <0xffffffff>
2019-03-01 09:28:07.860 IFMDriverServicesiOS[274:5768] critical: at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_canvas_draw_path (intptr,intptr,intptr) <0x00007>
2019-03-01 09:28:07.877 IFMDriverServicesiOS[274:5768] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.2.1.13/src/Xamarin.iOS/UIKit/UIApplication.cs:63
2019-03-01 09:28:07.923 IFMDriverServicesiOS[274:5768] critical: 0 IFMDriverServicesiOS 0x000000010356d564 GMSx_AbslInternalSpinLockWake + 800720
2019-03-01 09:28:07.923 IFMDriverServicesiOS[274:5768] critical: 1 IFMDriverServicesiOS 0x000000010357b234 mono_pmip + 16100
2019-03-01 09:28:07.923 IFMDriverServicesiOS[274:5768] critical: 2 libsystem_platform.dylib 0x00000001822cc9f0 <redacted> + 56
2019-03-01 09:28:07.924 IFMDriverServicesiOS[274:5768] critical: 3 libSkiaSharp 0x00000001043b4bbc gr_glinterface_has_extension + 1348628
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
The app has been terminated.
Failed to Stop app: An error occured on client IDB412377 while executing a reply for topic xvs/idb/4.12.3.77/stop-app
The app has been terminated.