simple popup with webview crashes on iOS
See original GitHub issueHi guys, need help with something, don’t know what is happening. I have a simple popup page in my xamarin form project:
<StackLayout >
<WebView x:Name="myWebView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
</WebView>
</StackLayout>
Right now I’m passing the string url after InitializeComponent() in xaml.cs file:
myWebView.Source = new UrlWebViewSource { Url = url};
And I call this within a TapGestureRecognizer
Navigation.PushPopupAsync(new MyPopUpPage("https://my-url..."));
and I got the following error (nothing but this on stacktrace):
iOS[35217:341188] void _WebThreadLock(), 0x129b7b040: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now…
I already tried with the latest pre-release version (1.1.4.154-pre) on iOS but still has the same error. Any clue? What am I missing? This code is working fine on Droid, only has this error on iOS
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (3 by maintainers)

Top Related StackOverflow Question
I found the solution,
If you run in main thread will solve the issue as below.
Device.BeginInvokeOnMainThread(async () => { await Navigation.PushPopupAsync(page, false); });
Thanks
@Nandulucky Try this https://devblogs.microsoft.com/xamarin/making-ios-11-even-easier-xamarin-forms/ this solved my issue