Bug 35441 - Application crash when override WKUIDelegate
Summary: Application crash when override WKUIDelegate
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.1 (iOS 9.1)
Hardware: All Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
: 35440 ()
Depends on:
Blocks:
 
Reported: 2015-10-31 23:51 UTC by andection
Modified: 2015-12-02 17:09 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description andection 2015-10-31 23:51:44 UTC
Hello.

I use WKWebView and I want to handle links with target='_blank' and javascript "window.open(..)". For this purpose I have to override CreateWebView of  WKUIDelegate. But application crash when I try to navigate by links. It is seems like a bug. Could you help me?

Stack trace from application output: 2015-10-29 05:34:47.013 OpenWindowBug[1727:683771] critical: Stacktrace:

2015-10-29 05:34:47.013 OpenWindowBug[1727:683771] critical: at <0xffffffff> 2015-10-29 05:34:47.014 OpenWindowBug[1727:683771] critical: at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff> 2015-10-29 05:34:47.014 OpenWindowBug[1727:683771] critical: at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/2320/7426bd76/source/maccore/src/UIKit/UIApplication.cs:77 2015-10-29 05:34:47.014 OpenWindowBug[1727:683771] critical: at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/2320/7426bd76/source/maccore/src/UIKit/UIApplication.cs:60 2015-10-29 05:34:47.014 OpenWindowBug[1727:683771] critical: at OpenWindowBug.Application.Main (string[]) [0x00008] in /Users/andection/Projects/OpenWindowBug/OpenWindowBug/Main.cs:12 2015-10-29 05:34:47.015 OpenWindowBug[1727:683771] critical: at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff> 2015-10-29 05:34:47.015 OpenWindowBug[1727:683771] critical: Native stacktrace:

2015-10-29 05:34:47.047 OpenWindowBug[1727:683771] critical: 0 OpenWindowBug 0x0000000100259c6c mono_handle_native_sigsegv + 260 2015-10-29 05:34:47.048 OpenWindowBug[1727:683771] critical: 1 OpenWindowBug 0x0000000100266bb8 mono_sigsegv_signal_handler + 328 2015-10-29 05:34:47.048 OpenWindowBug[1727:683771] critical: 2 libsystem_platform.dylib 0x0000000198c9194c _sigtramp + 68 2015-10-29 05:34:47.048 OpenWindowBug[1727:683771] critical: 3 OpenWindowBug 0x0000000100349e98 _ZL16get_raw_gchandleP11objc_object + 44 2015-10-29 05:34:47.048 OpenWindowBug[1727:683771] critical: 4 OpenWindowBug 0x0000000100349e38 _ZL12get_gchandleP11objc_object + 24 2015-10-29 05:34:47.048 OpenWindowBug[1727:683771] critical: 5 OpenWindowBug 0x0000000100349aa8 xamarin_get_gchandle + 24 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 6 OpenWindowBug 0x00000001003499fc xamarin_get_nsobject_with_type_for_ptr_created + 100 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 7 OpenWindowBug 0x0000000100353b40 xamarin_trampoline + 4144 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 8 WebKit 0x0000000189aea1dc + 448 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 9 WebKit 0x0000000189ba66d4 + 148 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 10 WebKit 0x0000000189bc5dc8 + 328 2015-10-29 05:34:47.049 OpenWindowBug[1727:683771] critical: 11 WebKit 0x0000000189a728d0 + 128 2015-10-29 05:34:47.050 OpenWindowBug[1727:683771] critical: 12 WebKit 0x0000000189bf8478 + 36 2015-10-29 05:34:47.050 OpenWindowBug[1727:683771] critical: 13 WebKit 0x0000000189a30244 + 136 2015-10-29 05:34:47.051 OpenWindowBug[1727:683771] critical: 14 WebKit 0x0000000189a2e2c4 + 112 2015-10-29 05:34:47.051 OpenWindowBug[1727:683771] critical: 15 WebKit 0x0000000189a30388 + 120 2015-10-29 05:34:47.051 OpenWindowBug[1727:683771] critical: 16 JavaScriptCore 0x000000018533f110 + 484 2015-10-29 05:34:47.051 OpenWindowBug[1727:683771] critical: 17 JavaScriptCore 0x000000018533f76c + 36 2015-10-29 05:34:47.051 OpenWindowBug[1727:683771] critical: 18 CoreFoundation 0x0000000183758544 + 24 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 19 CoreFoundation 0x0000000183757fd8 + 540 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 20 CoreFoundation 0x0000000183755cd8 + 724 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 21 CoreFoundation 0x0000000183684ca0 CFRunLoopRunSpecific + 384 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 22 GraphicsServices 0x000000018e8c0088 GSEventRunModal + 180 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 23 UIKit 0x0000000188d9cffc UIApplicationMain + 204 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 24 OpenWindowBug 0x00000001000cab7c wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 348 2015-10-29 05:34:47.052 OpenWindowBug[1727:683771] critical: 25 OpenWindowBug 0x000000010008a57c UIKit_UIApplication_Main_string___intptr_intptr + 44 2015-10-29 05:34:47.053 OpenWindowBug[1727:683771] critical: 26 OpenWindowBug 0x000000010008a53c UIKit_UIApplication_Main_string___string_string + 172 2015-10-29 05:34:47.053 OpenWindowBug[1727:683771] critical: 27 OpenWindowBug 0x0000000100086efc OpenWindowBug_Application_Main_string__ + 156 2015-10-29 05:34:47.053 OpenWindowBug[1727:683771] critical: 28 OpenWindowBug 0x00000001001d6244 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 244 2015-10-29 05:34:47.053 OpenWindowBug[1727:683771] critical: 29 OpenWindowBug 0x0000000100268e98 mono_jit_runtime_invoke + 1264 2015-10-29 05:34:47.053 OpenWindowBug[1727:683771] critical: 30 OpenWindowBug 0x00000001002cc4c8 mono_runtime_invoke + 124 2015-10-29 05:34:47.054 OpenWindowBug[1727:683771] critical: 31 OpenWindowBug 0x00000001002d0d50 mono_runtime_exec_main + 400 2015-10-29 05:34:47.054 OpenWindowBug[1727:683771] critical: 32 OpenWindowBug 0x0000000100361710 xamarin_main + 1840 2015-10-29 05:34:47.054 OpenWindowBug[1727:683771] critical: 33 OpenWindowBug 0x00000001002272f4 main + 96 2015-10-29 05:34:47.054 OpenWindowBug[1727:683771] critical: 34 libdyld.dylib 0x0000000198ab28b8 + 4

2015-10-29 05:34:47.055 OpenWindowBug[1727:683771] critical:

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.

I created a simple UIViewController to reproduction this bug. For reproduction click in any search result link.

public partial class ViewController : UIViewController
{
    public ViewController (IntPtr handle) : base (handle)
    {
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();

        var webView = new WKWebView (View.Bounds, new WKWebViewConfiguration ());
        webView.UIDelegate = new WDelegate ();
        View.AddSubview (webView);
        webView.LoadRequest (NSUrlRequest.FromUrl (NSUrl.FromString ("https://www.google.ru/#newwindow=1&q=gg")));
    }

    private class WDelegate:WKUIDelegate
    {
        public override WKWebView CreateWebView (WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)
        {
            Console.WriteLine ("CreateWebView ");
            return null;
        }
    }

    private class WNDelegate:WKNavigationDelegate
    {
        public override void DecidePolicy (WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler)
        {
            decisionHandler (WKNavigationActionPolicy.Allow);
        }
    }
}
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-11-02 04:15:09 UTC
*** Bug 35440 has been marked as a duplicate of this bug. ***
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-12-02 17:02:05 UTC
I've tried a sample project [1], and it works fine in both the simulator and on device with Xamarin.iOS 9.1 and Xamarin.iOS 9.2

Are you still having this problem? Can you try my test project and see if it crashes for you?

[1] https://files.xamarin.com/~rolf/bug35441.zip
Comment 3 andection 2015-12-02 17:09:09 UTC
Thank you Rolf. It is working for me now.