HaishinKit.swift: Crash on NetSocket.swift

Hello,

Describe the bug Crashlytics is reporting a crash on NetSocket.swift line 103 (NetSocket.doOutputProcess(_:maxLength:)).

To Reproduce I can’t reproduce it but it occured 10 times in 1 week in production (not many users).

Smartphone (please complete the following information): Exemple of impacted devices :

  • 12.4.1 (16G102) / iPhone 7
  • 12.3.1 (16F203) / iPhone 6s
  • 12.4.2 (16G114) / iPad Air
  • 11.4.1 (15G77) / iPhone 6

Additional context Here is the logs from Crashlytics :

Crashed: com.haishinkit.HaishinKit.NetSocket.output
0  CoreFoundation                 0x1d8cdd3e0 CFHash + 372
1  CoreFoundation                 0x1d8d70780 CFBasicHashGetCountOfKey + 204
2  CoreFoundation                 0x1d8cde8bc CFSetContainsValue + 116
3  CoreFoundation                 0x1d8cd6e18 CFRunLoopRemoveSource + 164
4  CFNetwork                      0x1d93ebc98 SocketStream::write(__CFWriteStream*, unsigned char const*, long, CFStreamError*) + 592
5  CoreFoundation                 0x1d8cec0c0 CFWriteStreamWrite + 300
6  HaishinKit                     0x10138dba4 NetSocket.doOutputProcess(_:maxLength:) + 103 (NetSocket.swift:103)
7  HaishinKit                     0x10138d98c closure #1 in NetSocket.doOutput(data:locked:) + 49 (NetSocket.swift:49)
8  HaishinKit                     0x1013355d8 thunk for @escaping @callee_guaranteed () -> () (<compiler-generated>)
9  libdispatch.dylib              0x1d8788a38 _dispatch_call_block_and_release + 24
10 libdispatch.dylib              0x1d87897d4 _dispatch_client_callout + 16
11 libdispatch.dylib              0x1d8732320 _dispatch_lane_serial_drain$VARIANT$mp + 592
12 libdispatch.dylib              0x1d8732e3c _dispatch_lane_invoke$VARIANT$mp + 428
13 libdispatch.dylib              0x1d873b4a8 _dispatch_workloop_worker_thread + 596
14 libsystem_pthread.dylib        0x1d8969114 _pthread_wqthread + 304
15 libsystem_pthread.dylib        0x1d896bcd4 start_wqthread + 4
crash_info_entry_1
*** CFHash() called with NULL ***

Have you any idea how to fix it ? Thanks !

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@floriangbh If the protocol is RTMPS, please set it like this

rtmpConnection.requireNetworkFramework = true
let params = NWParameters.tls
rtmpConnection.parameters = params
rtmpConnection.requireNetworkFramework = true

@mkrn I have already used RTMPNWSocket to avoid this problem instead of RTMPSocket. RTMPNWSocket is using Network.framework (>= iOS 12)

According to Apple suggestion:

Discouraged APIs Foundation and SCNetworkReachability

+[NSStream getStreamsToHostWithName:port:inputStream:outputStream:] +[NSStream getStreamsToHost:port:inputStream:outputStream:] -[NSNetService getInputStream:outputStream:]

NSNetServiceListenForConnections NSSocketPort SCNetworkReachability

Confirm. Happened going in and out of wifi zone, trying to reconnecting frequently. Will see if a catch can be added anywhere. Crash identical to @Goule