Post

Replies

Boosts

Views

Activity

app crash on network framework in iOS15.1
i use network.framewrok to create a tcp connection, but crashed on iOS15.1,here is some code: - (void)connectToIP:(NSString *)ip         onPort:(uint16_t)port   completionHandler:(ConnectCallbackV2)callback {   if (@available(iOS 12.0, *)) {           _callback = [callback copy];       nw_parameters_configure_protocol_block_t tlsConfig = NW_PARAMETERS_DISABLE_PROTOCOL;     nw_parameters_configure_protocol_block_t tcpConfig = ^(nw_protocol_options_t options) {       NW_PARAMETERS_DEFAULT_CONFIGURATION(options);       nw_tcp_options_set_connection_timeout(options, 5.0f);       nw_tcp_options_set_enable_keepalive(options, true);     };     if (!_socket) {       _socket = nw_connection_create(                       nw_endpoint_create_host(ip.UTF8String, [NSString stringWithFormat:@"%d", port].UTF8String),                       nw_parameters_create_secure_tcp(tlsConfig, tcpConfig));     }     nw_connection_set_queue(_socket, _delegateQueue);     nw_connection_set_state_changed_handler(self->_socket, ^(nw_connection_state_t state, nw_error_t _Nullable error) {       switch (state) {         case nw_connection_state_failed:         case nw_connection_state_cancelled: {          // some logic           break;         }         case nw_connection_state_ready: {           // some logic           break;         }         default: {           // some logic           break;         }       }     });           nw_connection_start(self->_socket);   } } and crash as follow: Thread 14 name: Thread 14 Crashed: 0 libobjc.A.dylib 0x000000019935f488 objc_retain + 8 (NSObject.mm:1775) 1 libnetwork.dylib 0x0000000181a11620 nw_parameters_get_logging_disabled + 56 (parameters.m:7335) 2 libnetwork.dylib 0x0000000181a0a52c __nw_connection_cancel_inner_block_invoke + 72 (connection.m:0) 3 libdispatch.dylib 0x000000018096d914 _dispatch_call_block_and_release + 32 (init.c:1517) 4 libdispatch.dylib 0x000000018096f660 _dispatch_client_callout + 20 (object.m:560) 5 libdispatch.dylib 0x0000000180976de4 _dispatch_lane_serial_drain + 672 (inline_internal.h:2601) 6 libdispatch.dylib 0x000000018097798c _dispatch_lane_invoke + 444 (queue.c:3937) 7 libdispatch.dylib 0x0000000180978c74 _dispatch_workloop_invoke + 1796 (inline_internal.h:0) 8 libdispatch.dylib 0x00000001809821a8 _dispatch_workloop_worker_thread + 656 (queue.c:6727) 9 libsystem_pthread.dylib 0x00000001f18860f4 _pthread_wqthread + 288 (pthread.c:2541) 10 libsystem_pthread.dylib 0x00000001f1885e94 start_wqthread + 8 the full crash log as file: 2021-12-01_23-42-12.3309_+0800-187b0dda38e36fd6d38ef0939f691bee85e31d9b.crash how can i fix this problem?
3
0
860
Dec ’21