Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebView error if we leave page while it's navigating #20627

Closed
ESO-ST opened this issue Feb 15, 2024 · 2 comments · Fixed by #21436 or #21718
Closed

WebView error if we leave page while it's navigating #20627

ESO-ST opened this issue Feb 15, 2024 · 2 comments · Fixed by #21436 or #21718
Labels
area-controls-webview WebView fixed-in-8.0.40 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@ESO-ST
Copy link

ESO-ST commented Feb 15, 2024

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.

ObjCRuntime.ObjCException
  Message=Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Completion handler passed to -[Microsoft_Maui_Platform_MauiWebViewUIDelegate webView:contextMenuConfigurationForElement:completionHandler:] was not called
Native stack trace:
	0   CoreFoundation                      0x00007ff80048d28d __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007ff800057894 objc_exception_throw + 48
	2   CoreFoundation                      0x00007ff80048d16b -[NSException initWithCoder:] + 0
	3   WebKit                              0x00000001119ba879 _ZN6WebKit28CompletionHandlerCallCheckerD2Ev + 127
	4   WebKit                              0x0000000111a223d5 _ZNK3WTF20ThreadSafeRefCountedIN6WebKit28CompletionHandlerCallCheckerELNS_17DestructionThreadE0EE5derefEv + 33
	5   WebKit                              0x00000001121a0a69 _ZZN3WTF8BlockPtrIFvP26UIContextMenuConfigurationEE12fromCallableIZ70-[WKContentView(WKInteractionPreview) continueContextMenuInteraction:]E5$_102EES4_T_ENUlPKvE_8__invokeES9_ + 31
	6   libsystem_blocks.dylib              0x00007ff8000c1214 _call_dispose_helpers_excp + 45
	7   libsystem_blocks.dylib              0x00007ff8000c1ea5 _Block_release + 232
	8   libdispatch.dylib                   0x00007ff80014bd3a _dispatch_client_callout + 8
	9   libdispatch.dylib                   0x00007ff80015aac0 _dispatch_main_queue_drain + 1420
	10  libdispatch.dylib                   0x00007ff80015a526 _dispatch_main_queue_callback_4CF + 31
	11  CoreFoundation                      0x00007ff8003e9850 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	12  CoreFoundation                      0x00007ff8003e418b __CFRunLoopRun + 2463
	13  CoreFoundation                      0x00007ff8003e3409 CFRunLoopRunSpecific + 557
	14  GraphicsServices                    0x00007ff80a650187 GSEventRunModal + 137
	15  UIKitCore                           0x000000011b1df3a2 -[UIApplication _run] + 972
	16  UIKitCore                           0x000000011b1e3e10 UIApplicationMain + 123
	17  libxamarin-dotnet-debug.dylib       0x00000001056f850a xamarin_UIApplicationMain + 58
	18  libmonosgen-2.0.dylib               0x0000000105e960f5 do_icall + 341
	19  libmonosgen-2.0.dylib               0x0000000105e94887 do_icall_wrapper + 295
	20  libmonosgen-2.0.dylib               0x0000000105e855a6 mono_interp_exec_method + 3990
	21  libmonosgen-2.0.dylib               0x0000000105e82d13 interp_runtime_invoke + 259
	22  libmonosgen-2.0.dylib               0x0000000105f69748 mono_runtime_invoke_checked + 136
	23  libmonosgen-2.0.dylib               0x0000000105f7109b mono_runtime_exec_main_checked + 107
	24  libmonosgen-2.0.dylib               0x0000000105dd5482 mono_jit_exec + 354
	25  libxamarin-dotnet-debug.dylib       0x000000010573cbea xamarin_main + 1898
	26  WebViewCrashMidLoad                 0x0000000103dd4a04 main + 68
	27  dyld                                0x00000001047023ee start_sim + 10
	28  ???                                 0x00000001089f13a6 0x0 + 4439610278
  Source=Microsoft.iOS
  StackTrace:
   at ObjCRuntime.Runtime.ThrowNSException(IntPtr ns_exception) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 507
   at ObjCRuntime.Runtime.throw_ns_exception(IntPtr exc) in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:line 279
   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
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at WebViewCrashMidLoad.Program.Main(String[] args) in C:\Users\ortiz\source\repos\WebViewCrashMidLoad\WebViewCrashMidLoad\Platforms\iOS\Program.cs:line 13

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

@ESO-ST ESO-ST added the t/bug Something isn't working label Feb 15, 2024
@samhouts samhouts added platform/iOS 🍎 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert labels Feb 15, 2024
@mikeparker104 mikeparker104 added the partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with label Feb 20, 2024
@Eilon Eilon added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Feb 21, 2024
@RoiChen001
Copy link
Collaborator

RoiChen001 commented Mar 21, 2024

Can repro it at iOS platform on 17.10.0 Preview 2 (8.0.10 &8.0.6).
ios20627

@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed potential-regression This issue described a possible regression on a currently supported version., verification pending labels Mar 21, 2024
@PureWeen PureWeen added this to the .NET 8 SR4 milestone Mar 21, 2024
@ESO-ST
Copy link
Author

ESO-ST commented Apr 8, 2024

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.

@PureWeen PureWeen modified the milestones: .NET 8 SR4, .NET 8 SR5 Apr 15, 2024
@Eilon Eilon added area-controls-webview WebView and removed legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-webview WebView fixed-in-8.0.40 migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert partner/cat 😻 this is an issue that impacts one of our partners or a customer our advisory team is engaged with platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
Status: Done
6 participants