0

我在使用带有新 Xamarin Unified iOS API 的 WKWebView 时遇到了一些问题,它在加载时崩溃并出现 EXC_BAD_ACCESS (SIGABRT) - KERN_INVALID_ADDRESS 异常(必须为此挖掘电话日志,Visual Studio 中没有任何显示。

我希望有人对此有一些经验。下面似乎是有问题的代码,它在经典 API 中运行良好(尽管由于 API 差异而进行了微小的更改)。如果我注释掉 3 WKWebView 行,以及将其添加到控制器的行,应用程序就会运行。注意:Window、Controller、WKWebView都是appdelegate类的参数。

public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
    Window = new UIWindow(UIScreen.MainScreen.Bounds);
    Window.BackgroundColor = UIColor.White;
    Window.MakeKeyAndVisible();

    Controller = new UIViewController();
    Controller.View.AutosizesSubviews = true;
    Window.RootViewController = Controller;

    var wkConfig = new WKWebViewConfiguration();
    WKWebView = new WKWebView(new CGRect(0, 20, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height - 20), wkConfig);
    WKWebView.LoadRequest(new NSUrlRequest(new NSUrl(RazorRouting.GetRootUrl())));

    Controller.View.AddSubview(WKWebView);

    return true;
}

这是崩溃报告的相关部分(崩溃线程堆栈跟踪)

Incident Identifier: 4C8B4F14-0412-48AC-A94A-70BEDFB07A07
CrashReporter Key:   35ac6193617557278e0d2ddbc984b0442b429f07
Hardware Model:      iPhone5,3
Process:             OurAppNameiOS [2311]
Path:                /private/var/mobile/Containers/Bundle/Application/003A0100-F79D-48A5-BEB5-    24CC9568E49A/OurAppNameiOS.app/OurAppNameiOS
Identifier:          com.OurApp.OurAppName
Version:             1.0 (1.0)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2014-10-28 07:57:50.403 -0400
Launch Time:         2014-10-28 07:57:45.692 -0400
OS Version:          iOS 8.1 (12B411)
Report Version:      105

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000004
Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x3766fdfc __pthread_kill + 8
1   libsystem_pthread.dylib         0x376edd32 pthread_kill + 58
2   libsystem_c.dylib               0x3760f904 abort + 72
3   OurAppNameiOS   0x00c15866 0xe1000 + 11749478
4   OurAppNameiOS   0x00c1de5c 0xe1000 + 11783772
5   libsystem_platform.dylib        0x376e9878 _sigtramp + 40
6   WebKit                          0x2d6820a6 -[WKWebView initWithFrame:configuration:] + 570
7   OurAppNameiOS   0x00bd80c0 0xe1000 + 11497664
8   OurAppNameiOS   0x00bb6ba4 0xe1000 + 11361188
9   OurAppNameiOS   0x000eb4b0 0xe1000 + 42160
10  OurAppNameiOS   0x0029d5a0 0xe1000 + 1820064
11  OurAppNameiOS   0x00c20058 0xe1000 + 11792472
12  OurAppNameiOS   0x00c5d296 0xe1000 + 12042902
13  OurAppNameiOS   0x00bf0a5c 0xe1000 + 11598428
14  OurAppNameiOS   0x00bf1584 0xe1000 + 11601284
15  UIKit                           0x2cd6c71c -[UIApplication     _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 280
16  UIKit                           0x2cf615aa -[UIApplication     _callInitializationDelegatesForMainScene:transitionContext:] + 2354
17  UIKit                           0x2cf63af6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1370
18  UIKit                           0x2cf6e374 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 32
19  UIKit                           0x2cf62384 -[UIApplication workspaceDidEndTransaction:] + 128
20  FrontBoardServices              0x2ffcf0e6 __31-[FBSSerialQueue performAsync:]_block_invoke     + 10
21  CoreFoundation                  0x2980939a __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 10
22  CoreFoundation                  0x2980865c __CFRunLoopDoBlocks + 212
23  CoreFoundation                  0x29806dde __CFRunLoopRun + 758
24  CoreFoundation                  0x2975520c CFRunLoopRunSpecific + 472
25  CoreFoundation                  0x2975501e CFRunLoopRunInMode + 102
26  UIKit                           0x2cd663ea -[UIApplication _run] + 554
27  UIKit                           0x2cd611cc UIApplicationMain + 1436
28  OurAppNameiOS   0x00bd8e00 0xe1000 + 11501056
29  OurAppNameiOS   0x00bada10 0xe1000 + 11323920
30  OurAppNameiOS   0x00bad9d0 0xe1000 + 11323856
31  OurAppNameiOS   0x000ea27c 0xe1000 + 37500
32  OurAppNameiOS   0x0029d5a0 0xe1000 + 1820064
33  OurAppNameiOS   0x00c20058 0xe1000 + 11792472
34  OurAppNameiOS   0x00c5d296 0xe1000 + 12042902
35  OurAppNameiOS   0x00c60516 0xe1000 + 12055830
36  OurAppNameiOS   0x00c60354 0xe1000 + 12055380
37  OurAppNameiOS   0x00c0ead4 0xe1000 + 11721428
38  OurAppNameiOS   0x00cb18c4 0xe1000 + 12388548
39  OurAppNameiOS   0x00bf2700 0xe1000 + 11605760
40  libdyld.dylib                   0x375a9aac start + 0
4

1 回答 1

1

这可能是由 Xamarin.iOS 统一 API 项目的 Visual Studio 构建过程中的错误引起的,该错误会导致特殊统一nfloat基元类型出现问题(请参阅https://bugzilla.xamarin.com/show_bug.cgi?id=23868#c14)。

我在WKWebView这里专门针对此崩溃提交了第二个错误:https ://bugzilla.xamarin.com/show_bug.cgi?id=24151 。我怀疑这个新错误最终将作为旧错误的副本解决。

于 2014-10-30T04:58:42.830 回答