Performance – 2.1
Your app crashes on an iPad and an iPhone running iOS 9.3.5 connected >to an IPv6 network when we:
Specifically,when we touch the More button in the bottom right hand corner of the app it crashed.
我花了很多时间在ipv6上阅读并得出结论,它可能是我正在使用的可达性类.
我有几个问题,如何修改代码以包含ipv6:
public class Reachability { class func isConnectedToNetwork() -> Bool { var zeroAddress = sockaddr_in(sin_len: 0,sin_family: 0,sin_port: 0,sin_addr: in_addr(s_addr: 0),sin_zero: (0,0)) zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress)) zeroAddress.sin_family = sa_family_t(AF_INET) let defaultRouteReachability = withUnsafePointer(&zeroAddress) { SCNetworkReachabilityCreateWithAddress(kcfAllocatorDefault,UnsafePointer(IncIDent IDentifIEr: C86A011D-2913-4FFE-992A-0E359781CECDCrashReporter Key: ae6778b695dfd22e7ce7236f09740cb14847b427HarDWare Model: xxxProcess: Fibre [3135]Path: /private/var/containers/Bundle/Application/8F9AF4E2-D64C-4C0C-8BF0-2C8FE63580EA/***IDentifIEr: ***Version: 1 (4.1.5)Code Type: ARM-64 (Native)Parent Process: launchd [1]Date/Time: 2016-09-08 17:51:55.55 -0700Launch Time: 2016-09-08 17:51:52.52 -0700OS Version: iOS 9.3.5 (13G36)Report Version: 105Exception Type: EXC_BREAKPOINT (SIGTRAP)Exception Codes: 0x0000000000000001,0x0000000100032b54Triggered by Thread: 5Filtered syslog:None foundGlobal Trace Buffer (reverse chronological seconds):6148914686.196010 CFNetwork 0x0000000181b0a0a4 NSURLConnection finished with error - code -10036148914686.196214 CFNetwork 0x0000000181ad5d50 http load Failed (error code: -1003 [12:8])6148914686.196214 CFNetwork 0x0000000181a596a8 _CFNetworkIsConnectedToInternet returning 1,flagsValID: 1,flags: 0x26148914686.196815 CFNetwork 0x0000000181abc184 TCP Conn 0x136fe5290 Failed : error 0:-65554 [-65554]6148914686.196815 CFNetwork 0x0000000181abbe7c TCP Conn 0x136fe5290 complete. fd: -1,err: -655546148914686.196982 CFNetwork 0x0000000181abd3a8 TCP Conn 0x136fe5290 event 3. err: -655546148914686.198890 CFNetwork 0x0000000181abd480 TCP Conn 0x136fe5290 started6148914686.200546 CFNetwork 0x0000000181b17e5c Creating default cookie storage with default IDentifIEr6148914686.200546 CFNetwork 0x0000000181b17e28 Faulting in CFhttpcookiestorage singleton6148914686.200546 CFNetwork 0x0000000181b69e50 Faulting in NShttpcookiestorage singleton6148914688.516532 AppleJPEG 0x0000000182e9626c [0x13808ee00] Created sessionThread 0 name: dispatch queue: com.apple.main-threadThread 0:0 libsystem_kernel.dylib 0x0000000180fb4fd8 mach_msg_trap + 81 libsystem_kernel.dylib 0x0000000180fb4e54 mach_msg + 722 CoreFoundation 0x00000001813ecc60 __CFRunLoopServiceMachPort + 1963 CoreFoundation 0x00000001813ea964 __CFRunLoopRun + 10324 CoreFoundation 0x0000000181314c50 CFRunLoopRunspecific + 3845 GraphiCSServices 0x0000000182bfc088 GSEventRunModal + 1806 UIKit 0x00000001865fa088 UIApplicationMain + 2047 Fibre 0x0000000100020b94 0x100004000 + 1176528 libdyld.dylib 0x0000000180eb28b8 start + 4Thread 1 name: dispatch queue: com.apple.NSURLSession-workThread 1:0 libsystem_kernel.dylib 0x0000000180fd14d8 kevent_qos + 81 libdispatch.dylib 0x0000000180e944a8 _dispatch_kq_update + 1522 libdispatch.dylib 0x0000000180e94404 _dispatch_mgr_wakeup + 483 libdispatch.dylib 0x0000000180e91a40 _dispatch_queue_wakeup_with_qos_slow + 404 libdispatch.dylib 0x0000000180e8d694 _dispatch_queue_drain + 13325 libdispatch.dylib 0x0000000180e84f80 _dispatch_queue_invoke + 4646 libdispatch.dylib 0x0000000180e8f390 _dispatch_root_queue_drain + 7287 libdispatch.dylib 0x0000000180e8f0b0 _dispatch_worker_thread3 + 1128 libsystem_pthread.dylib 0x0000000181099470 _pthread_wqthread + 10929 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 2 name: dispatch queue: com.apple.libdispatch-managerThread 2:0 libdispatch.dylib 0x0000000180e96b84 _dispatch_source_kevent_unregister + 3161 libdispatch.dylib 0x0000000180e8390c _dispatch_source_invoke + 7082 libdispatch.dylib 0x0000000180e8390c _dispatch_source_invoke + 7083 libdispatch.dylib 0x0000000180e8d694 _dispatch_queue_drain + 13324 libdispatch.dylib 0x0000000180e8dcd8 _dispatch_mgr_queue_drain + 445 libdispatch.dylib 0x0000000180e94734 _dispatch_mgr_invoke + 686 libdispatch.dylib 0x0000000180e83648 _dispatch_source_invoke + 0Thread 3:0 libsystem_kernel.dylib 0x0000000180fd0b48 __workq_kernreturn + 81 libsystem_pthread.dylib 0x0000000181099530 _pthread_wqthread + 12842 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 4:0 libsystem_kernel.dylib 0x0000000180fd0b48 __workq_kernreturn + 81 libsystem_pthread.dylib 0x0000000181099530 _pthread_wqthread + 12842 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 5 name: dispatch queue: NSOperationQueue 0x136f35cc0 :: NSOperation 0x136fe3590 (QOS: LEGACY)Thread 5 Crashed:0 Fibre 0x0000000100032b54 0x100004000 + 1913161 CFNetwork 0x0000000181a965ac __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_2 + 1802 Foundation 0x0000000181df0540 __NSBLOCKOPERATION_IS_CALliNG_OUT_TO_A_BLOCK__ + 163 Foundation 0x0000000181d42870 -[NSBlockOperation main] + 964 Foundation 0x0000000181d32e48 -[__NSOperationInternal _start:] + 6045 Foundation 0x0000000181df2934 __NSOQSchedule_f + 2246 libdispatch.dylib 0x0000000180e8147c _dispatch_clIEnt_callout + 167 libdispatch.dylib 0x0000000180e8d4c0 _dispatch_queue_drain + 8648 libdispatch.dylib 0x0000000180e84f80 _dispatch_queue_invoke + 4649 libdispatch.dylib 0x0000000180e8f390 _dispatch_root_queue_drain + 72810 libdispatch.dylib 0x0000000180e8f0b0 _dispatch_worker_thread3 + 11211 libsystem_pthread.dylib 0x0000000181099470 _pthread_wqthread + 109212 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 6:0 libsystem_kernel.dylib 0x0000000180fd0b48 __workq_kernreturn + 81 libsystem_pthread.dylib 0x0000000181099530 _pthread_wqthread + 12842 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 7:0 libsystem_kernel.dylib 0x0000000180fd0b48 __workq_kernreturn + 81 libsystem_pthread.dylib 0x0000000181099530 _pthread_wqthread + 12842 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 8:0 libsystem_kernel.dylib 0x0000000180fd0b48 __workq_kernreturn + 81 libsystem_pthread.dylib 0x0000000181099530 _pthread_wqthread + 12842 libsystem_pthread.dylib 0x0000000181099020 start_wqthread + 4Thread 9 name: com.apple.NSURLConnectionLoaderThread 9:0 libsystem_kernel.dylib 0x0000000180fb4fd8 mach_msg_trap + 81 libsystem_kernel.dylib 0x0000000180fb4e54 mach_msg + 722 CoreFoundation 0x00000001813ecc60 __CFRunLoopServiceMachPort + 1963 CoreFoundation 0x00000001813ea964 __CFRunLoopRun + 10324 CoreFoundation 0x0000000181314c50 CFRunLoopRunspecific + 3845 CFNetwork 0x0000000181a95bcc +[NSURLConnection(Loader) _resourceLoadLoop:] + 4126 Foundation 0x0000000181e0be4c __NSThread__start__ + 10007 libsystem_pthread.dylib 0x000000018109bb28 _pthread_body + 1568 libsystem_pthread.dylib 0x000000018109ba8c _pthread_body + 09 libsystem_pthread.dylib 0x0000000181099028 thread_start + 4Thread 5 crashed with ARM Thread State (64-bit): x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000136db3890 x3: 0x0000000136f6dda0 x4: 0x0000000100039250 x5: 0x0000000000000001 x6: 0x0000000000000000 x7: 0x0000000000000a30 x8: 0x0000000136fd58f8 x9: 0x0000000000000004 x10: 0x0000000000000000 x11: 0x0000000000000000 x12: 0x0000000137091190 x13: 0x000005a1001e9247 x14: 0x00000000ffffffff x15: 0x00000000ffffffff x16: 0x00000001003ec47c x17: 0x0000000186e3db68 x18: 0x0000000000000000 x19: 0x0000000000000000 x20: 0x0000000136db3890 x21: 0x0000000000000000 x22: 0x0000000136fe5b50 x23: 0x0000000136f6dda0 x24: 0x8e00a063ef134017 x25: 0x00000000000000d8 x26: 0x0000000000020001 x27: 0x00000000240008ff x28: 0x0000000000010001 fp: 0x000000016e246a00 lr: 0x0000000181a965ac sp: 0x000000016e246980 pc: 0x0000000100032b54 cpsr: 0x20000000Binary Images:0x100004000 - 0x100193fff Fibre arm64 <a3baaae1e0f93363a87211e3e15a394e> /var/containers/Bundle/Application/8F9AF4E2-D64C-4C0C-8BF0-2C8FE63580EA/Fibre.app/Fibre0x10021c000 - 0x10041bfff libswiftCore.dylib arm64 <39ceee8206bb32809dab8ecba2e05d8e> /var/containers/Bundle/Application/8F9AF4E2-D64C-4C0C-8BF0-2C8FE63580EA/Fibre.app/Frameworks/libswiftCore.dylib)) } var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags(rawValue: 0) if SCNetworkReachabilityGetFlags(defaultRouteReachability!,&flags) == false { return false } let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0 let needsConnection = (flags.rawValue & UInt32(kSCNetworkFlagsConnectionrequired)) != 0 return isReachable && !needsConnection }}
因为我正在使用http请求,我的服务器也必须配置为ipv6吗?
任何帮助将非常感激!
崩溃日志:
after解决方法 如拒绝通知中所示,您的问题源于对仅IPv6和其他现代网络拓扑不再有效的假设.这里有两个步骤……>在建立连接之前,请勿使用可达性来“预检”.来自Apple的guide to supporting modern networks:
The Reachability APIs (see 07001) are intended for diagnostic purposes
0.0.0.0
IDentifying a connectivity issue. Many apps incorrectly use these APIs to proactively check for an Internet connection by calling the 07002 method and passing it an IPv4 address of169.254.0.0
,which indicates that there is a router on the network. However,the presence of a router doesn’t guarantee that an Internet connection exists. In general,avoID preflighting network reachability. Just try to make a connection and gracefully handle failures. If you must check for network availability,avoID calling the 07002 method. Call the 07004 method and pass it a hostname instead.Some apps also pass the 07002 method an IPv4 address of ,a self-assigned link-local address,to check for an active Wi-Fi connection. To check for Wi-Fi or cellular connectivity,look for the network reachability flag 07006 instead.
>在提交到App Store之前,使用仅IPv6网络进行测试.您可以set up a NAT64 gateway on your development Mac创建仅供IPv6测试的设备使用的IPv6网络.
在上述链接和WWDC16 session 714,“Networking for the Modern Internet”中,有更好的建议来支持IPv6和现代网络.
总结以上是内存溢出为你收集整理的ios – IPV6 Swift可达性全部内容,希望文章能够帮你解决ios – IPV6 Swift可达性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)