Closed ESO-ST closed 5 months ago
Can repro it at iOS platform on 17.10.0 Preview 2 (8.0.10 &8.0.6).
After using the nightly version of MAUI that has this fix, we now get this error
14:23:47:238 Unhandled Exception:
14:23:47:238 System.InvalidOperationException: VirtualView cannot be null here
14:23:47:238 at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IWebView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[WebKit.WKWebView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].get_VirtualView()
14:23:47:238 at Microsoft.Maui.Handlers.WebViewHandler.Microsoft.Maui.Handlers.IWebViewHandler.get_VirtualView()
14:23:47:238 at Microsoft.Maui.Platform.MauiWebViewNavigationDelegate.DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action`1 decisionHandler)
14:23:47:238 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
14:23:47:238 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKi
14:23:47:238 t/UIApplication.cs:line 94
14:23:47:238 at WebViewCrashMidLoad.Program.Main(String[] args) in C:\Users\Salem\source\repos\WebViewCrashMidLoad\WebViewCrashMidLoad\Platforms\iOS\Program.cs:line 13
14:23:47:238 2024-04-05 19:23:47.148522+0100 WebViewCrashMidLoad[39290:225312] Unhandled managed exception: VirtualView cannot be null here (System.InvalidOperationException)
14:23:47:238 at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IWebView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[WebKit.WKWebView, Microsoft.iOS, Version=17.2.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].get_VirtualView()
14:23:47:238 at Microsoft.Maui.Handlers.WebViewHandler.Microsoft.Maui.Handlers.IWebViewHandler.get_VirtualView()
14:23:47:238 at Microsoft.Maui.Platform.MauiWebViewNavigationDelegate.DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action`1 decisionHandler)
14:23:47:238 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
14:23:47:238 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/
14:23:47:238 src/UIKit/UIApplication.cs:line 94
14:23:47:238 at WebViewCrashMidLoad.Program.Main(String[] args) in C:\Users\Salem\source\repos\WebViewCrashMidLoad\WebViewCrashMidLoad\Platforms\iOS\Program.cs:line 13
I do want to note that our WebView is inside a Mopups Popup page, the repro project was also updated to reflect that and the issue is reproduceable there as well.
Description
If we have a webview and it's navigating somewhere, say for example we pressed on a link and it's loading a page, if while that navigation is taking place we leave the page where the webview is, we get an error.
Steps to Reproduce
press click me to open a modal page with a web view. press on a link in the webview to make it load that url, while that's taking place leave the page by pressing click me.
Link to public reproduction project repository
https://github.com/ESO-ST/WebViewCrashMidLoad
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 15
Did you find any workaround?
No response
Relevant log output
No response