crash during opening link with target=“_blank” in WKWebView

I am writing iOS application which wrap web site. And I want to handle links with target="_blank". But my applications crash on devices (And works good in simulators).

I tried to use solutions from Why is WKWebView not opening links with target="_blank". But it does not work for me. Application crashed before CreateWebView method.

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.

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);
    }
}

}

Answers

  • DarrenMcGrath86DarrenMcGrath86 GBMember ✭✭

    Hi andrew did you ever find an answer to this issue? I am also having the same problem

Sign In or Register to comment.